Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of markjugg (792)

Tuesday August 22, 2006
10:25 PM

refactoring CGI::App for Perl6: simple recipe for porting

[ #30726 ]
Today's work on porting CGI::Application to Perl6 was special because some of the tests actually began to pass. :) To make this happen, the test scripts themselves have been translated to Perl6. In this case, I also had a dozen test application modules which needed to be converted.

It turned these test modules included fairly simple Perl object syntax, and could largely be converted to Perl6 by running the following find-and-replace functions on them with my editor:

s/use strict;\n/          # use strict is no longer needed!
s/^sub /method /          # convert subs to methods
s/.*my $self = shift;\n// # ...and get rid of this!
s/\$self->/self./         # shorten object syntax
s/1;//                    # 1; is gone!

As yesterday, the theme in porting to Perl6 is code removal and simplification. Just by casually browsing the code for refactoring possibilities, I removed an additional 12 lines of code with little effort.

Next I just need to keep working my way through the test suite, continuing to convert the test scripts themselves to Perl6, and see what else needs to change for the tests to pass.

Today's learning experience was that ref returns more and different values than it used to, and I haven't found good documentation about this yet. So far, I've found that "Pair", "Array" and "Array::Const" are possibilities. So far, I like the simplicity of just HASH and ARRAY from Perl5.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I have been wondering at Perl6 and whether it will be too *complex* and whether I would just stick with Perl5. You postings have given me hope that even I will be able to make the transition. : )
    • The biggest deficiency I see in Perl6 right now is that CPAN hasn't been ported to Perl6 yet. :)

      I expect I'll be preferring Perl5 for production for a long time. One of things I have yet to explore is Perl5 embedding, so Perl5 modules can be used in Perl6.

      The definitely seems like a transitional solution, though, due to the extra overhead and complexity of it.