$str1 = "But I think the device doesn't allow writes or something and that's causing this issue."; $str2 = "But I think the device allow writes or something and that's causing this issue."; #### open (FHH, ">error.txt")|| die $!; $str1 = "But I think the device doesn't allow writes or something and that's causing this issue."; $str2 = "But I think the device allow writes or something and that's causing this issue."; my $line = 0; my $pat = qr/$str2/; while($str1){ $line++; if($str1 =~m/($pat)/igs){ my $pre = $`; } else{ print FHH "Line $line:$pre \'$pat\' is missing from $str2." } }