... push @indexes, sprintf '%03d', first_index { $_ eq $place } @firstText; ... #### print sprintf "%08d\n", $_ for @indexes;