Is there a way to iterate the other way around (from the start of the path to the end instead from the end to the start)?

Sure, Path::Class::Dir's components will give you the filename split into its components, like File::Spec's splitdir that I mentioned above. Note that I'm assuming you're talking about *NIX systems, where the two behave the same, I'm not sure at the moment how they behave in respect to volume names on Windows or other OSes.

Update: You've edited your node to add the following. Please see "It is uncool to update a node in a way that renders replies confusing or meaningless" in How do I change/delete my post? and mark your updates as such.

Also, does it know how to handle with multi-links? For example a/b -> c/d -> e/f? In case it's a link, should I iterate until I get the actual path?

You seem to be asking about readlink, which only reads the target of the link you're asking it to, it won't follow chains of links. You'll either have to do that manually, which is a little tricky (see e.g. my script relink), or if you just want to know the final target, use Cwd's abs_path.


In reply to Re^5: Creating a bash script "on the fly" (updated) by haukex
in thread Creating a bash script "on the fly" by ovedpo15

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.