There's more than one way to do things | |
PerlMonks |
Re: How do monks create paths?by doom (Deacon) |
on Apr 06, 2008 at 22:29 UTC ( [id://678688]=note: print w/replies, xml ) | Need Help?? |
Other people have pointed you to File::Spec->catfile: that's the way to do it for portable code (e.g. something you expect to post to CPAN). What I do for local, unix-only hackery is: I never include a trailing slash on directories, and always build up new paths with double-quoted strings. A typical script might look something like this:
My personal opinion is that doing things like this is a win for readability: Also, note the stack of "use"s at the top... it's hard to do anything The Right Way in perl without leaning on the standard library a lot. These days I use script templates that include a dozen "use"s by default, so I don't have to try to remember what module "fileparse" is hidden inside of, and so on.
In Section
Seekers of Perl Wisdom
|
|