my $str ="OK file1\nline2"; print "OK1\n" if $str =~ qr/^OK file1$/m; print "OK2\n" if $str =~ /^OK file1$/m;