use strict; use warnings; my $actualPrompt = 'TERM = (hp) '; while (){ chomp; $actualPrompt =~ /$_/ ? print "$_\tMatches\n" : print "$_\tDoes not match\n"; }; __DATA__ TERM\s/=\s/(hp/)\s TERM\s=\s\(hp\)\s