in reply to help with lazy matching

As already mentioned, regexes work from left to right and the regex engine will not backtrack if if succeeds. Your "lazy matching" would work if you wanted to get only the first part of the string, but here, when it gets to the end of the string, it has succeeded and has no reason to take only the end part.

In theory, you could get around that and use a non-greedy quantifier by first reversing the string and then reversing the result, with this:

$ perl -E 'my $c = reverse "/foo/bar/baz/bat"; say "matched ", scal +ar reverse ($1) if $c =~ m{(.+?)/};' matched bat
But that's a bit ugly and unnatural.

The alternative if to forget about non-greedy quantifier for such a case and use character class, as in the old days where there was no non-greedy quantifier:

$ perl -E 'my $c = "/foo/bar/baz/bat"; say "matched $1" if $c =~ m{/ +(\w+)$};' matched bat
or:
$ perl -E 'my $c = "/foo/bar/baz/bat"; say "matched $1" if $c =~ m{/( +[^/]+)$};' matched bat
Please also note how I used { } as regex delimiters (theare are many others that you can use, most non-letter or number characters, such as []  (), ##, §§,etc.) so that I did not have to escape the /.

It was not really mandatory in such a simple example, but it often makes life easier when you have slashes in your regex.

Update: modified the first code snippet which did not reverse the result. Thanks to AnomalousMonk for pointing out the mistake.