open my $FILE , "<", "db.txt" or print "Unable to open 'db.txt' $!"; while ( my $string = <$FILE> ) { if ( $msg =~ /$string/i ) { print "$string found\n"; } } close $FILE;