Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > activestate perl via shell() on XP, module location problem

Reply
Thread Tools

activestate perl via shell() on XP, module location problem

 
 
doolittle
Guest
Posts: n/a
 
      10-27-2006
Hi,

I have a perl program - mymodscript.pl - which works from the command
line on XP, but when i try to run it from visual basic with the
shell("perl mymodscript.pl") command, it complains that it can't find
mymodule.pm.

mymodule.pm is one that i have written (and which mymodscript.pl
needs), and put in the same directory as mymodscript.pl.

I know that the shell command works because if i change mymodscript.pl
so that it doesn't need mymodule.pm, it works both from the command
line and from visual basic using shell("perl myscript.pl")

I have tried using perl -I path-to-my-modules, but that didn't work.

Does anyone have an explanation?

thanks

 
Reply With Quote
 
 
 
 
Sisyphus
Guest
Posts: n/a
 
      10-27-2006

"doolittle" <(E-Mail Removed)> wrote in message
..
..
>
> mymodule.pm is one that i have written (and which mymodscript.pl
> needs), and put in the same directory as mymodscript.pl.
>


There's a bit of a trap there. The fact that 'mymodule.pm' is in the same
directory as 'mymodscript.pl' doesn't really count for much.
What *is* important is that 'mymodule.pm' is in @INC.

On Win32, that will *typically* (but not necessarily) mean that
'mymodule.pm' has to be in either 'C:\perl\lib', 'C:\perl\site\lib' or the
cwd (current working directory).

To check all of this, your 'mymodscript.pl' could (untested):

use Cwd;
print getcwd, "\n";
for(@INC) { print "$_\n" unless $_ eq '.'}

If 'mymodule.pm' is not located in *any* of the specified locations, then
that's your problem.

Cheers,
Rob


 
Reply With Quote
 
 
 
 
doolittle
Guest
Posts: n/a
 
      10-27-2006
Thanks for the suggestion, i think i understand (a bit of) whats going
on:

The shell("mymodscript.pl") command runs in

C:/Documents and Settings/ibm/My Documents

this 'works' somehow although mymodscript.pl isn't in this directory,
its in

C:/Documents and Settings/ibm/My Documents/perl

which is where the modules are, which is why perl can't find them.

So i could put the module in C:/Perl/site/lib, or alter @INC to include

C:/Documents and Settings/ibm/My Documents/perl

 
Reply With Quote
 
Brian Helterline
Guest
Posts: n/a
 
      10-27-2006
doolittle wrote:
> Thanks for the suggestion, i think i understand (a bit of) whats going
> on:
>
> The shell("mymodscript.pl") command runs in
>
> C:/Documents and Settings/ibm/My Documents
>
> this 'works' somehow although mymodscript.pl isn't in this directory,
> its in
>
> C:/Documents and Settings/ibm/My Documents/perl
>
> which is where the modules are, which is why perl can't find them.
>
> So i could put the module in C:/Perl/site/lib, or alter @INC to include
>
> C:/Documents and Settings/ibm/My Documents/perl
>


Another method to use for modules you don't have in @INC is:

# yoursript.pl
use FindBin;
use lib $FindBin::Bin; # adds location of script to @INC
use yourmodule;


This method requires yourmodule.pm be in the same directory as
yourscript.pl

--
brian
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveState Perl and MinGW [was: Perl 5.14 Windows Strawberry Perl 64 bits] Dilbert Perl Misc 0 11-10-2011 02:20 PM
Html issue with Module::Build (Win32 ActiveState Perl) Dilbert Perl Misc 1 12-20-2009 06:44 PM
Location, location, location =?Utf-8?B?VHJhY2V5?= Wireless Networking 2 02-17-2007 08:37 PM
Activestate Perl and original Perl both on Mac OS Tiger Jake Wiley Perl Misc 14 06-16-2005 10:47 PM
Boxed Perl or ActiveState Perl? Vittorio Perl Misc 3 04-02-2004 05:48 PM



Advertisments