while () { chomp; my @words = lc($_) =~ /[a-z-]+/g; # Needs improvement? my $has_date = grep /^d/ && /a/ && /t/ && /e/, @words; my $has_publish = grep /^publish/, @words; print "'$_' matched\n" if $has_date && $has_publish; } __DATA__ The book was published on the date "20-08-2009".