$ perl -E 'my $c = "/foo/bar/baz/bat"; say "matched $1" if $c =~ m{/([^/]+)$};' matched bat