in reply to Search string giving incorrect results

Maybe you need to do something like ...
my $IN = quotemeta($in); if ($thread_data[4] =~ m/$IN{for}/i) { print $thread_data[0]; }