[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Extended prototypes in current Perl



#!perl -w
use strict;

my $code = <<'EOT';

sub foo ($a, $b, $c, @d) {
  print "The quick brown $a ${c}s over the lazy $b.",
        reverse(@d),
        "\n";
}
sub bar ($) {}
foo('fox', 'dog', 'jump', 'Perl 6.', 'Inspired by ', "\n");

EOT

$code =~ s/sub((?:\s+\w+)?)\s+\((.*?[A-Za-z].*?)\)\s+{/
           my $p = $2; $p =~ tr#$%@##cd; "sub$1($p){my($2)=\@_;"/eg;

print $code;
eval $code; die $@ if $@;

__END__

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe