Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Is "require '/foo/bar/baz.pm'" portable? (http://www.velocityreviews.com/forums/t891655-is-require-foo-bar-baz-pm-portable.html)

J Krugman 04-04-2005 04:36 PM

Is "require '/foo/bar/baz.pm'" portable?
 


Is something like

require '/path/to/some/Module.pm';

portable?

I could have sworn that there was a perlvar that contained the OS's
directory separator, but I can't find it, so either my memory is
playing me a trick, or this variable was eliminated at some point.

File::Spec is the generally accepted way to construct filenames
portably. But I have read in a couple of places that it is OK to
give Perl paths with the Unix directory separator like the one
above even in systems that don't use this separator. If this is
the case, then Perl must be doing the translation internally, which
would greatly diminish the utility of File::Spec, and make the
various OS-specific File::Spec::* modules all but useless.

What gives?

TIA!

jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.


Brian McCauley 04-04-2005 05:01 PM

Re: Is "require '/foo/bar/baz.pm'" portable?
 


J Krugman wrote:
> Is something like
>
> require '/path/to/some/Module.pm';
>
> portable?


Yes.
>
> I could have sworn that there was a perlvar that contained the OS's
> directory separator, but I can't find it, so either my memory is
> playing me a trick, or this variable was eliminated at some point.


No, on some OSs it's not even as simple as a single character.

> File::Spec is the generally accepted way to construct filenames
> portably. But I have read in a couple of places that it is OK to
> give Perl paths with the Unix directory separator like the one
> above even in systems that don't use this separator. If this is
> the case, then Perl must be doing the translation internally, which
> would greatly diminish the utility of File::Spec, and make the
> various OS-specific File::Spec::* modules all but useless.
>
> What gives?


File::Spec is mostly needed for doing stuff like constructing arguments
for system() or parsing filenames passed into Perl in the OS's native
format.



All times are GMT. The time now is 06:45 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57