Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:58:19+00:00 2026-06-11T17:58:19+00:00

My perl script must run on windows as well as Linux server. As the

  • 0

My perl script must run on windows as well as Linux server. As the script runs, I have to update the registry for specific things. When I use “use Win32::Registry” It works fine on windows but on Linux it gives errors regardless of the following if statement.

if ($OS =~ /Windows/ )
{
use Win32::Registry;
...
...
}

In my view, perl loads “use” at compilation time and that must be the problem. What can I do so that Perl does not load use win 32 command when running on Linux?

I tried using

if ($OS =~ /Windows/ )
{
require Win32::Registry;
...
...
} 

with this, the script runs fine on both servers but it saves binary values in registry and not string value.

So how can I make the Perl script run on both servers and save string values in registry?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:58:20+00:00Added an answer on June 11, 2026 at 5:58 pm
    use Foo;
    

    is

    BEGIN {
       require Foo;
       import Foo;
    }
    

    so use

    BEGIN {
       if ($OS =~ /Windows/)
          require Win32::Registry;
          import Win32::Registry;
       }
    }
    

    or

    use if $OS =~ /Windows/, 'Win32::Registry';
    
    • use
    • if pragma
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a perl script to send email using the gmail's smtp server:
My name is abbi My first perl script run on linux machine This script
Using perl 5.8.8 on windows server I am writing a perl cgi script using
I have a Perl script that needs to run following an annual schedule with
I have a Perl script where variables must be initialized before the script can
I have this script #!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %acc =
I have a need to upgrade a Perl CGI script where the users must
I have a python script which must call a perl script to get data
I have a Perl script that takes user input and creates another script that
I have a perl script URL which gives me a ZIP file, it processes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.