http://www.perlmonks.org?node_id=548909


in reply to What this pattern matches

That code stores in $1 a copy of $b with everything after the last "_" removed, including the "_" itself.

There are exceptions.
$1 is left unchanged if $b contains no "_".
$1 is left unchanged if $b contains nothing before the last "_".
$1 is left unchanged if $b contains nothing after the last "_".

When executed in list context, it returns $1 on match or an empty list on failure to match.