in reply to Matching a scalar variable

You probably want something more like this:

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;