in reply to Matching a scalar variable

It probably finds nothing because there is a \n at the end of each line you read from a text file. Adding chomp(@idstring); or chomp $string; will take care of that

Also if $string has regex special characters in it, the result will be quite different from what you expect. Use \Q and \E to escape the special characters

I would suggest using foreach instead of while. Looks much cleaner that way and you don't need a $count variable:

foreach $string (@idstring) { chomp($string); if ($msg =~ m/.*\Q$string\E.*/i) { print "$string found"; last; } }

Update: Removed reference to $count in my loop, thanks to ssandv for spotting it