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

Discussion in 'Perl Misc' started by J Krugman, Apr 4, 2005.

  1. J Krugman

    J Krugman Guest

    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.
    J Krugman, Apr 4, 2005
    #1
    1. Advertising

  2. 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.
    Brian McCauley, Apr 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger

    Portable Coding Guidelines?

    Roger, Dec 17, 2004, in forum: VHDL
    Replies:
    0
    Views:
    537
    Roger
    Dec 17, 2004
  2. Eli Bendersky
    Replies:
    1
    Views:
    1,152
    Mike Treseler
    Mar 1, 2006
  3. =?Utf-8?B?c3VyZXNoX0Mj?=
    Replies:
    8
    Views:
    7,344
    =?Utf-8?B?TWFoZXNoIE5pbWJhbGthcg==?=
    May 3, 2005
  4. Albretch
    Replies:
    4
    Views:
    519
    Roedy Green
    Jun 18, 2004
  5. Replies:
    7
    Views:
    904
Loading...

Share This Page