The current code is on github under
https://github.com/drforr/Perl-Mogrify, but will change names upon release.
It's a configurable Perl5-Perl6 translator tool based heavily on Perl::Critic. You can use your own .perlmogrifyrc file to configure which translators you want to run, and eventually add and configure your own translators.
While I won't say that it compiles Perl5 to syntactically correct Perl6 100% of the time, I've tested it on DamianWare(tm), and with minimal intervention (changing package declarations, rewriting local *OUT mostly) 99% of Parse::RecDescent passed its compile-time check.
While most of the changes it does are trivial, they can be hard to get right. For instance, =~ is now ~~, ~ is now ^?, . is now ~, and -> is now .. Go ahead and figure out the right order to do those changes in vim or emacs, I'll wait for you. :)
In the meantime, it also changes your for() loops around, tidies map and grep, cleans up your filehandles, and changes your sigils from $x[0] to @x[0] like you've always secretly wanted to do.
As of release here's what it'll do:
- Add whitespace where needed - if(1), my($x), for(@z), qw(), qx()
- Translate non-decimal numbers: 0x12f, 0b1101, 017
- Properly interpolate numbers: \x{263a}, \N{LATIN LETTER CAPITAL X}
- Fix rational numbers: 32.
- Reformat here-docs: <<_EOF_;
- New Q operators: qw(), qr(), qx()
- Reformat strings: "\ua $hash{key}1 ${foo}"
- Print to filehandle: print FOO 43;
- C-style loops: for($i=0;$i<5;$i++)
- Perl-style loops: for my $x (@a)
- First-order expressions: map s/foo/bar/, keys %x
- Basic operators: !$a, $x . "foo"
- Package usage: use Foo;
- Constant declarations: use constant FOO => 1, Readonly my $FOO => 1
- Basic variables: $x->[3], @{ $x }, $x[2]++
- Special variables: @+, STDOUT, @ARGV
- Regular expressions: s/foo/bar/igx
- Sub prototypes: sub foo($)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.