DB<72> map {if ($x=(/b/../d/)) { $out[$x]=$_; $last=$x }} a..e,a..e,a..b,1..3,d..e; DB<73> x @out[1..$last] 0 'b' 1 1 2 2 3 3 4 'd' DB<74>