Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
When you have to create paths in your code from two or more strings, how exactly do you do it?
Do you use trailing slashes, leading slashes, and why?
Say for instance you have to programatically arrive at the path:
by combining sub-paths, you could do it like this (assume that the strings are, or may be, variables):/Foo/bar/baz/bax.txt
or like this:my $path = '/Foo' . '/bar' . '/baz' . '/bax.txt';
and you can get away on some systems doing it like this:my $path = '/Foo/' . 'bar/' . 'baz/' . 'bax.txt';
because double slashes aren't a problem.my $path = '/Foo/' . '/bar/' . '/baz/' . '/bax.txt';
Are there best practices, strong reasons for doing it one way and not another, platform gotchas, factional flame wars about the One True Way, etc?
I'm mostly asking because I have to do this quite often and every time I do it, I decide that one way is better than the other, then change my mind a day later. I'd appreciate some monastic wisdom to help me arrive at a Best Practice.
Nobody says perl looks like line-noise any more
kids today don't know what line-noise IS ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do monks create paths?
by kyle (Abbot) on Apr 06, 2008 at 03:14 UTC | |
Re: How do monks create paths?
by perrin (Chancellor) on Apr 06, 2008 at 04:18 UTC | |
Re: How do monks create paths? (Path::Class)
by lodin (Hermit) on Apr 06, 2008 at 10:24 UTC | |
Re: How do monks create paths?
by grep (Monsignor) on Apr 06, 2008 at 03:19 UTC | |
Re: How do monks create paths?
by Your Mother (Archbishop) on Apr 06, 2008 at 05:18 UTC | |
Re: How do monks create paths?
by doom (Deacon) on Apr 06, 2008 at 22:29 UTC | |
Re: How do monks create paths?
by Khen1950fx (Canon) on Apr 07, 2008 at 09:34 UTC |
Back to
Seekers of Perl Wisdom