Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: distribution config file

by rinceWind (Monsignor)
on Jun 19, 2006 at 15:27 UTC ( [id://556269]=note: print w/replies, xml ) Need Help??


in reply to Re: distribution config file
in thread distribution config file

There are two approaches to writing portable code to deal with paths. All systems running perl can cope with POSIX filenames, i.e. using '/' as a path separator. This works except when performing textual manipulation on a file spec in native format, though Windows can sometimes cope with a mixture of forward slashes and backslashes.

The other approach is to use File::Spec, Cwd and friends in conjunction with the native syntax. If you do this, stick to native syntax throughout. Note that some OSes e.g. VMS, don't have a single 'path separator' but something more complicated.

For more on this, see perldoc perlport and my YAPC portability talk slides.

By the way, I don't think your approach will work in the OP's case.__FILE__ is an alias for $0 as far as I am aware, so this may not contain any path separators at all.

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

Replies are listed 'Best First'.
Re^3: distribution config file
by IOrdy (Friar) on Jun 20, 2006 at 00:22 UTC
    "By the way, I don't think your approach will work in the OP's case.__FILE__ is an alias for $0 as far as I am aware, so this may not contain any path separators at all."

    "__FILE__ is the filename at that point in the program." -- Programming Perl.
    "$0 is the name of the program being executed." -- perldoc perlvar

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://556269]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-23 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found