pythonizer
pythonizer copied to clipboard
Translator (or more correctly transcriber) from Perl to Python
Enhancement: Implements signals and alarm() and also anonymous sub's. Sample perl code: $SIG{ALRM} = sub { die "timeout"; }; eval { alarm($TIME); ... alarm(0); }; if($@ =~ /timeout/) { ......
Multiline assignments of constant hashrefs generate bad code. For example: $i = { key1 => "val1", key2 => "val2", };
Quoted strings with nested brackets don't find the end properly: "If the delimiters are bracketing, nested pairs are also skipped. For example, while searching for a closing ] paired with...
Translating a line with multiple bash-style "and"s / "or"s generates hanging indents. For example: ($ec1 = $ar2equivc{$r1}) || ($ec1 = $ar2equivc{"$r1:stub"}) || ($ec1 = $r1); Leaves the indent level set...
Old perl scripts use `'` instead of `::` - not handled. Example: $tms_lib'HOME = "/ctms/ctms";
Bad code generated if last statement in block before else or elsif doesn't end in `;`, e.g. if(...) { next } else { ... } will spit out a line...
Complex hash RHS values produces syntax error in the generated code. For example: my %hop = ( "AClli" => $AClli, "ZClli" => $ZClli, "ID" => $circuitRow[$colNames{"ID"}], "mileage" => $circuitRow[$colNames{"mileage"}], "type"...
Don't assume a subscript for bare words if space before the [...] in a string. For example: "Usage: $prog [options] " Generates this code: f"Usage: {prog[options]}] " instead of this...
Regex with local sub call generates bad code. For example: next if exists $cl{$k} and strip($fac) =~ /^OC/; Generates: if k in cl and strip([fac])re.search(r'^OC',:
Bad code generated for pattern match with complex LHS. For example: while (not (($line = shift @lines) =~ /^!/))