Blue_Tiger
Blue_Tiger copied to clipboard
Perl 5 to Perl 6 Translator
Blue Tiger is an assistant for Perl 5 to Perl 6 translation.
How to try it without installing: git clone git://github.com/Util/Blue_Tiger.git cd Blue_Tiger bin/p526 path/to/program.pl > program_and_warnings.p6
Initial Author: Bruce Gray Email: bruce dot gray at acm dot org IRC: "Util" on freenode/#perl6
Pre-requisite modules: PPI 1.204_03 or higher
Currently handles (with examples): Mandatory: Operator changes . -> ~ Invariant sigils $hash{$key} -> %hash{$key} Casts @{$arrayref} -> @($arrayref) Nums with trailing. 42. -> 42.0 KeywordNoSpace if( -> if ( Bare hash keys $hash{KEY} -> %hash{'KEY'} map/grep comma @z=map {...} @a -> @z=map {...}, @a mapish EXPR @z=map !$, @a -> @z=map { !$ }, @a Optional: Warnings for user review of transforms.
Planned/TODO:
Mandatory:
for/loop for(;$i>5;$i++) -> loop (;$i>5;$i++)
foreach arrow for my $i (@a) -> for @a -> $i
open open my $fh,... -> my $fh = open...
bareword filehandle open FH, ... -> my $FH = open...
readline via <> <$fh> -> $fh.get (if scalar)
readline func readline $fh -> $fh.get (if scalar)
while readline while (<$fh>){} -> for $fh.lines {}
magic diamond while (<>){} -> for lines() {...}
ARGV/ARGS @ARGV -> @*ARGS
Hash init? => -> P5=> (sometimes)
rand function rand -> P5rand
qq changes "${foo}bar" -> "{$foo}bar"
"\l$foo" -> "{lc $foo}"
"\v"
double-underscore PACKAGE -> $?PACKAGE
indent-i_fiers "$foo_bar-30" -> "$foo_bar-30"
or -> "{$foo_bar}-30"
syntax collisions '\qq[...]' -> '\qq[...]'
(especially qq) "@array" -> "@array[]"
"$a.b()" -> "$a.b()"
"abc{def()}ghi" -> "abc{def()}ghi"
or -> qq:!c "abc{def()}ghi"
Unicode "\N{NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE}"
-> "\c[NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE]"
Unicode? Lots!
Optional (and configurable!):
Hashkey short form %hash{'KEY'} -> %hash<KEY>
Remove parens if ($foo) {} -> if $foo {}
func vs method @z=map {...} @a -> @[email protected]({...})
Infinite loop while (1) {...} -> loop {...}
qq un-hack "@{[ $a * 2 ]}" -> "{$a * 2}"
print/say print "Hi!\n" -> say "Hi!";
Regex improvements qr{ a [ ]+ b }x -> re{ a b } XXXX smart spacing?
Bad slurp for (