length == 9 and ! index $_, 5 #### $ perl -E ' my @strings = qw{1 234 5 678 567890123 qwerty}; say for grep +(length == 9 and ! index $_, 5), @strings; ' 567890123