README

January 29, 2014 · View on GitHub

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)Numswithtrailing.42.>42.0KeywordNoSpaceif(>if(Barehashkeysarrayref) 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>5;i++) -> loop (;i>5;i>5;i++) foreach arrow for my i(@a)>for@a>i (@a) -> for @a -> i open open my fh,...>myfh,... -> my fh = open... bareword filehandle open FH, ... -> my FH=open...readlinevia<><FH = open... readline via <> <fh> -> fh.get(ifscalar)readlinefuncreadlinefh.get (if scalar) readline func readline fh -> fh.get(ifscalar)whilereadlinewhile(<fh.get (if scalar) while readline while (<fh>){} -> for fh.linesmagicdiamondwhile(<>)>forlines()...ARGV/ARGS@ARGV>@ARGSHashinit?=>>P5=>(sometimes)randfunctionrand>P5randqqchanges"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" "\lfoo" -> "{lc foo}" "\v" double-underscore __PACKAGE__ -> ?PACKAGE indent-i_fiers "foobar30">"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 -> @z=@a.map({...}) 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 (<fh>){} -> for fh.slurp pick int(rand 12) -> (^12).pick pick array a[rand@a]>@a.pickHashinita[rand @a] -> @a.pick Hash init %h=map{=>1}@a -> %h = @a X=> 1 @ handling sub f{(n)=@_} -> sub f (n) {} Divides (nn % 2) == 0 -> n %% 2 List::Util comma first {...} @a -> first {...}, @a