Definitely go with File::Basename, and i like ikegami's solution above better than this one, but to directly translate your question of "find the last occurrence of \\ and then give me everything from that match to the end of the string" into a regex, i offer this:
$s =~ /\\(.*?)$/; # UPDATE: THIS IS WRONG!!! my $endPart = $1;
Four parts: 1) matches a (escaped) backslash 2) anchor to the end of the string with $ 3) capture all the stuff ( .* ) inbetween by surrounding w/parens 4) make that cature non-greedy with the ? -- this way it implicitly makes the \\ be the furthest one to the right in the string.
Update: OOPS. As pointed out, that greedy usage is wrong. I would just stick with the abover method of the non-backslash character class. Though this will work if matching the beginning of the string like /^(.*?)\\/
Update 2: I think what i originally intended was /.+\\(.*?)$/

As for grouping and back matching in general, the Tutorials and perldoc perlre and starting places.
Quick & dirty grouping overview: Basically the way grouping works is anything you put in parens will get captured, and the first capture will be stored in $1, the second in $2, and so on.
my $s = "This is a blurb"; if( $s =~ /(\S+)\s\S+\s\S+\s(\S+)/ ){ print "$1:$2"; # This:blurb }
Two quick notes: A) Always make sure the regex matched successfully before using $1, etc. B) You can prevent parens from capturing by using ?: like this: /(?:blah)/

In reply to Re: Pattern matching by davidrw
in thread Pattern matching by ketema

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.