diff options
author | matthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2007-09-12 18:11:34 +0000 |
---|---|---|
committer | matthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2007-09-12 18:11:34 +0000 |
commit | 7adfd53f17f66ffe93763e944ed1d3fc52a369dc (patch) | |
tree | 19e599e74419b41cbbe651fd226b81e8b73551d3 /script/moose_to_rclass.pl | |
parent | c728c97cb1061330e63c7cc048e768ef74988fe6 (diff) | |
download | reaction-7adfd53f17f66ffe93763e944ed1d3fc52a369dc.tar.gz reaction-7adfd53f17f66ffe93763e944ed1d3fc52a369dc.zip |
moved shit to trunk
Diffstat (limited to 'script/moose_to_rclass.pl')
-rwxr-xr-x | script/moose_to_rclass.pl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/script/moose_to_rclass.pl b/script/moose_to_rclass.pl new file mode 100755 index 0000000..67d0e73 --- /dev/null +++ b/script/moose_to_rclass.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl + +# THIS IS A FUCKING CHEESY HACK. DON'T RUN IT ON ANYTHING YOU CARE ABOUT +# (and don't have in svn at least. Oh, and it breaks horribly on with) + +use strict; +use warnings; + +my $data; + +foreach my $file (@ARGV) { + open IN, $file; + { local $/; $data = <IN>; } + close IN; + unless ($data =~ m/(.*?\n)(?:extends (.*?);)?\n+?(has.*)\n(1;\s*\n.*)/s) { + warn "Failed to match for ${file}\n"; + next; + } + my ($front, $super_list, $body, $rest) = ($1, $2, $3, $4); + my @supers = split(/\s*,\s*/, $super_list); + my $pkg = (split(/\//, $file))[-1]; + $pkg =~ s/\.pm//; + $body =~ s/^sub (\S+) {$/method $1 => sub {/mg; + $body =~ s/^}$/};/mg; + $body =~ s/^(\S+) '([^\+]\S+)' =>/$1 $2 =>/mg; + $body =~ s/^/ /mg; + my $is_list = join('', map { "is $_, " } @supers); + open OUT, '>', $file; + print OUT "${front}class ${pkg} ${is_list}which {\n${body}\n};\n\n${rest}"; + close OUT; +} + +exit 0; |