Making the .+ non-greedy doesn't change that the dot is perfectly willing to match any / in the inputs (since a dot just matches any (non-newline, by default) character). It's still going to start at the left-most "/" that it sees (the first character) and then start gobbling up one or more things-which-match-dot (which includes all the subsequent letters and "/"s) until it hits the end of the line. If you'd explicitly asked for things-which-are-not-"/" using [^/]+ instead you'd have had more luck (e.g. m{/ ([^/]+) $}x).
Of course this could just be a slight XY problem and you really want File::Basename or Path::Tiny instead . . .
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: Why does this non-greedy match not work?
by Fletch
in thread Why does this non-greedy match not work?
by Special_K
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |