a Python2 to Python3 print fixer in perl
\h matches horizontal white spaces

/x modifier instructs regex to ignore white spaces (readability)

/m modifier instructs ^ $ anchors to match begin/end of line, instead of string!

local $/; # read all text at once

while (my $line = &lt;&gt;) {
    $line =~ s/print \s+ (.+? (?: [^\\]\h*$ ) )/print($1)/xgsm;
    print $line;
}