Home > Archive > PERL Miscellaneous > October 2006 > activestate perl via shell() on XP, module location problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
activestate perl via shell() on XP, module location problem
|
|
| doolittle 2006-10-30, 7:10 pm |
| 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
| |
| Sisyphus 2006-10-30, 7:10 pm |
|
"doolittle" <spam.meplease@ntlworld.com> 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
| |
| doolittle 2006-10-30, 7:10 pm |
| 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
| |
| Brian Helterline 2006-10-30, 7:10 pm |
| 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
|
|
|
|
|