If you really need things to work across different OS, use the
File::Spec module. It's great for platform independent Perl code.
Here's a quick example.
use File::Spec;
my $file = File::Spec->catfile (qw (usr, localfardle whang dang doodle
extc));
print "File: $file\n";
Prints:
File: usr/localfardle/whang/dang/doodle/etc
Which is close.
my $file = File::Spec->catfile ("", qw (usr, localfardle whang dang
doodle extc));
Will put in the leading "/". But there are probably other options that
will force it to put in an absolute path.
There are also other options available if you want to use non-native
file spces. See the docs for this module.
Curtis
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David
Jacoby
Sent: Wednesday, February 24, 2010 8:28 AM
To: [email protected]
Subject: Re: "Leaning Toothpicks" across OSs
I agree. Yeah, you could put a regex like
s{\\}{/}gmx
in there, but I'd fix it not work around it.
Brian Raven wrote:
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> [email protected]
> Sent: 24 February 2010 16:08
> To: [email protected]
> Subject: "Leaning Toothpicks" across OSs
>
>> O Wise Ones,
>
> Yeah, right.
>
>> (Slap me twice for this one--got my operating systems mixed up!)
>
> Happy to oblige.
>
>> This is one of those silly moments when I can't remember a simple
> trick, and I'm too cotton-pickin'
>> lazy to dig through all my Perl books to find it. I'm maintaining
>> some
> old DOS code that has pathed
>> Linux filenames suffering from LTS. you know...
> \/usr\/local\/fardle\/whang\/dang\/doodle\/etc.....
>> I know there's a way to eliminate all that \/ stuff, but I can't
>> think
> of it to save my life. I'll
>> gladly accept a Gibbs head-slap (for all you fellow NCIS fans out
> there), if it's accompanied by the
>> solution.
>
> Not sure what you mean by eliminate them. Couldn't you just use an
> editor to change them to /?
>
> HTH
>
--
Dave Jacoby Address: WSLR S049
Genomics Core Programmer Mail: [email protected]
Purdue University Phone: 765.49.67368
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs