-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
70 lines (64 loc) · 3.18 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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 -> @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.pick
Hash init %h=map{$_=>1}@a -> %h = @a X=> 1
@_ handling sub f{($n)=@_} -> sub f ($n) {}
Divides ($n % 2) == 0 -> $n %% 2
List::Util comma first {...} @a -> first {...}, @a