Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows equivalent of Unix/Linux "require"

Status
Not open for further replies.

ednit

Technical User
Jan 31, 2006
16
US
I am trying to work on a script on my local pc (Windows), but I cannot figure out how to use the "require" command on my computer (that works on my linux hosting account).

Example for my hosting account:

Code:
#!/usr/bin/perl

require "somesub.pm";

print "content-type: text/html\n\n";

Example for my computer (which doesn't work):

Code:
#!"D:\web\xampp\perl\bin\perl.exe"

require "somesub.pm";

print "content-type: text/html\n\n";

Maybe I'm missing a module? I'm not sure. Any help would be appreciated.

Thanks.
 
the code you posted is good as long as "somesub.pm" is included in @INC or is in the same directory as the script, most likely the cgi-bin.

Try this:

Code:
#!"D:\web\xampp\perl\bin\perl.exe"

eval {
   require "somesub.pm";
};
if ($@) {
   print "content-type: text/html\n\n";
   print "Error including the required file:\n";
   print "$@\n";
   exit;
}
else {
   print "content-type: text/html\n\n"; 
   print "Module somesub.pm is installed";
   exit;
}

I don't recommend you use xampp. Install perl and apache and all the other stuff like mysql and php yourslef, it is not as hard as xampp wants you to believe it is. I've seen enough problems with it posted on forums to doubt it works very well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top