script/moose_to_rclass.pl untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod n/a totaltotal 0.0% 0 / 34 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2  
3 # THIS IS A FUCKING CHEESY HACK. DON'T RUN IT ON ANYTHING YOU CARE ABOUT
4 # (and don't have in svn at least. Oh, and it breaks horribly on with)
5  
6 use strict;
7 use warnings;
8  
9 my $data;
10  
11 foreach my $file (@ARGV) {
12 open IN, $file;
13 { local $/; $data = <IN>; }
14 close IN;
15 unless ($data =~ m/(.*?\n)(?:extends (.*?);)?\n+?(has.*)\n(1;\s*\n.*)/s) {
16 warn "Failed to match for ${file}\n";
17 next;
18 }
19 my ($front, $super_list, $body, $rest) = ($1, $2, $3, $4);
20 my @supers = split(/\s*,\s*/, $super_list);
21 my $pkg = (split(/\//, $file))[-1];
22 $pkg =~ s/\.pm//;
23 $body =~ s/^sub (\S+) {$/method $1 => sub {/mg;
24 $body =~ s/^}$/};/mg;
25 $body =~ s/^(\S+) '([^\+]\S+)' =>/$1 $2 =>/mg;
26 $body =~ s/^/ /mg;
27 my $is_list = join('', map { "is $_, " } @supers);
28 open OUT, '>', $file;
29 print OUT "${front}class ${pkg} ${is_list}which {\n${body}\n};\n\n${rest}";
30 close OUT;
31 }
32  
33 exit 0;