\d - a digit \w - a word character \s - whitespace. #### foreach my $line ( @lines ) { next unless $line =~ m/^\d{6} \w{3}/; # Will match '111111 aaa' where 1 is any # number, a any char. next unless $line =~ m/^\d+\s+\w+/; # Will match any number followed by any word. # The '^' anchors the search to the beginning # of the string. }