After a recent project that used File::Spec, File::Find, and others
I'd like to add another section to
tye's
File::Spec review
('the good', 'the bad', and 'the ugly') ...
(Please forgive me for using unix paths in the following discussion)
The Unexpected
File::Spec->canonpath( $path ); does remove extra '/' and '/.' from paths,
but it does not, however, fix paths like
'/a/1/../2' into '/a/2'.
To do that I had to resort to regexps something like
$path =~ s(\.\./)()g - which introduces platform-specific code
and defeats the purpose of using File::Spec in the first place.
Q: What is the correct (x platform) method for removing 'dir/..' from paths?
A note on my ignorance: None of the systems that I use perl on
(all 5.005_003 or older) have documentation (or code) for either
abs2rel() or rel2abs() in File::Spec, or File::Spec::Unix.
Are these new in 5.6?
Perhaps theses functions are part of the answer to my question.
All the best,
DouglasDD
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.