Your "code snippet" begins with:
The array contents are ...
But there is no array in the code snippet, and this makes your post incoherent. (That means we can't understand what you are trying to ask us about.)

I think one or more monks, in replying to one or more of your earlier posts, has mentioned modules like File::Spec and File::Basename. Have you looked into those? Have you tried them? Is there some problem that you have with trying them?

Others have also told you about using split -- e.g. like this:

my @a = qw/C:\abc\dfg\axy C:\abc\dfg\#@$#@$@\hwllo/; for ( @a ) { my @p = split /\\/; print "last-component= ", $p[-1], " and next-to-last= ", $p[-2], " +\n"; }
Have you tried anything like that yet? Is there some problem with trying that?

In reply to Re: unable to fomulate right regular expression to fetch the intermediate and last word from a line (windows path) using delimiter "\" by graff
in thread unable to fomulate right regular expression to fetch the intermediate and last word from a line (windows path) using delimiter "\" by suniln

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.