That was a surprise for me to see / in MSWin32 paths. Dump of %INC:
$VAR1 = {
'bytes.pm' => 'C:/strawberry/perl/lib/bytes.pm',
'XSLoader.pm' => 'C:/strawberry/perl/lib/XSLoader.pm',
'Carp.pm' => 'C:/strawberry/perl/lib/Carp.pm',
'warnings/register.pm' => 'C:/strawberry/perl/lib/warnings/register.pm',
'File/Spec/Unix.pm' => 'C:/strawberry/perl/lib/File/Spec/Unix.pm',
'Exporter.pm' => 'C:/strawberry/perl/lib/Exporter.pm',
'vars.pm' => 'C:/strawberry/perl/lib/vars.pm',
'strict.pm' => 'C:/strawberry/perl/lib/strict.pm',
'warnings.pm' => 'C:/strawberry/perl/lib/warnings.pm',
'File/Spec.pm' => 'C:/strawberry/perl/lib/File/Spec.pm',
'overload.pm' => 'C:/strawberry/perl/lib/overload.pm',
'base.pm' => 'C:/strawberry/perl/lib/base.pm',
'File/Spec/Win32.pm' => 'C:/strawberry/perl/lib/File/Spec/Win32.pm',
'Data/Dumper.pm' => 'C:/strawberry/perl/lib/Data/Dumper.pm',
'App/whichpm.pm' => 'lib/App/whichpm.pm'
};
There is
perl -Mstrict -e "print $INC{'strict.pm'}"
C:/strawberry/perl/lib/strict.pm
but
perl -e "($f)=split/;/,$ENV{PATH};print $f"
C:\Windows\system32
The values in %INC
always follow Unix conventions, regardless of which platform you’re on.
(I cannot find this documented anywhere in the POD that ships with perl.)
Re:Yes
Aristotle on 2010-06-20T19:00:45
Actually it’s only the key that’s always in Unix convention. The value will be some ill-descript Unixish mishmash on non-Unix platforms: usually, the
@INC
entry under which the file was found, verbatim, plus the same string as the key, joined with a slash regardless of OS – but not always, especially on VMS – and never on Symbian.Uhm, I hope this helps.
Re:Yes
slanning on 2010-06-21T06:27:57
I only found a reference to it in perlfaq5. It points out there that DOS does handle forward slashes in place of backslashes (though you have to put quotes around the file name, or it thinks the slash is an option).
C:\Users\slanning>more > foo.txt
hi there
^C
C:\Users\slanning>perl -e "open(F, 'c:/Users/slanning/foo.txt') || die$!; while(<F>){print}"
hi there
C:\Users\slanning>perl -e "open(F, 'c:\Users\slanning\foo.txt') || die $!; while(<F>){print}"
hi there