Acme::Metification - Give Perl the power of Metaprogramming!


Acme-Metification documentation  | view source Contained in the Acme-Metification distribution.

Index


NAME

Top

Acme::Metification - Give Perl the power of Metaprogramming!

SYNOPSIS

Top

  use Acme::Metification;
  # This is line 0

  sub faculty {
     my $no = shift;
     my $fac = 1;
     $fac *= ($no--);
     return $fac if $no == 0;
     recursemeta depth => 100, 5, 7
     # ^^ insert lines 5 to 7 up to 100 times
     return $fac;
  }

  print faculty(4); # prints 24 after quite some time

NOTE

Top

Do not, I repeat, do not use in production code. But then again, the features are useless, so you wouldn't anyway.

DESCRIPTION

Top

This module gives you some meta-programming abilites within Perl. It uses source filters to do evil things with your source.

The module allows the use of two new functions. They must appear on separate lines in your code:

meta

Syntax:

  meta [line_no1], [line_no2]

meta replaces itself with the code lines ranging from [line_no1] to [line_no2]. The first line after "use Acme::Metification;" is considered line 0.

Of course, those lines may contain meta or recursemeta directives, so beware of deep recursion.

recursemeta

Similar to meta with some exceptions. Syntax:

  recursemeta depth => [depth], [line_no1], [line_no2]

[depth] is the maximum depth to recurse into in case recursemeta directives are inserted. However, meta directives will be recursed into deeply.

EXAMPLES

Top

Execute examples from POD docs
  use Acme::Metification;

  # Execute code from pod docs:

  meta 9, 11

  =pod

  =head1 Example

    foreach (0..5) {
      print "Acme::Metification rocks!\n";
    }

  =cut

Transform slow recursion into blazingly fast code!
  use Acme::Metification;

  sub faculty {
     my $no = shift;
     my $fac = 1;
     $fac *= ($no--);
     return $fac if $no == 0;
     recursemeta depth => 100, 4, 6
     return $fac;
  }

  print faculty(4);

AUTHOR

Top

Steffen Mueller, <smueller@cpan.org<gt>

COPYRIGHT AND LICENSE

Top

SEE ALSO

Top

Filter::Simple by Damian Conway


Acme-Metification documentation  | view source Contained in the Acme-Metification distribution.