Giving it a closer look, I experience a strange behaviour. I'm using
ActiveState Perl on WinXp here.
The following script has been used for testing:
use File::Spec;
BEGIN
{
my ($volume,$softwaredir,$librarydir);
($volume,$softwaredir) = File::Spec->splitpath(__FILE__);
$librarydir = File::Spec->catpath($volume,$softwaredir,'librarydemo');
unshift (@INC,$librarydir);
printf "%s\n" x @INC,@INC;
};
require "sample.pl";
print "\nCalling test variable from sample.pl:\n";
print $SAMPLE::test;
Using the IDE (Perl Express, not really a pro tool, but free), it brings this
output:
C:\Programme\Perl Express\Debug\librarydemo
C:/Perl/site/lib
C:/Perl/lib
.
Then it stops executing with the following error:
Can't locate sample.pl in @INC...
Guess the problem is the "\" instead of "/" in the path. What have I done wrong
here or is this something related to the File::Spec module (not to call it a
bug ;-) ?
HOWEVER running the same on command line works as intended, although (!) a
strange path is added to @INC:
C:\Dokumente und Einstellungen\Tobias\Eigene Dateien\Meine Perl-Programme>perl
require1.cgi
librarydemo
C:/Perl/site/lib
C:/Perl/lib
.
Calling test variable from sample.pl:
12345
No error message, anything works as expected; although just "librarydemo" is
added as path.
And a second HOWEVER that makes it more strange, at least for me. I gave it a
try on my local Apache 2 web server (127.0.0.1/cgi-bin/require.cgi; just added
the line print "Content-type: text/plain; charset=utf-8\n\n"; to ensure that no
malformed header error is generated). It gives this output:
C:/Programme/Apache Software Foundation/Apache2.2/cgi-bin/librarydemo
C:/Perl/site/lib
C:/Perl/lib
.
Calling test variable from sample.pl:
12345
There, anything is as it should - correct slashes used in the path, no error.
Since I intend to write CGI programs, I'm happy so far :-)
But I have no explanation for this behavior nor do I know how this may or may
not influence reliability or cross platform suitability of programs using this
way of adding paths to @INC.
But I wonder if someone experienced can bring more light into this and is able
to explain what happened here ?
Tobias.
__________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/