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


in reply to Problem with pattern match

If you know you want the last thing on the line, use an anchor ($).
push(@last, $1) && last if /(\w+)\.bld$/; #or if you want 'three.bld' in the push: push(@last, $1) && last if /(\w+\.bld)$/;