December 2011 Archives

Introducing here

I've just published the first release of the here module, a mechanism for safely inserting generated code into a compiling program. this can be used to write macros, cut down on boiler plate, and to implement new declarations, all without ever having to parse any perl source code.

you operate on code as data, as you normally would when metaprogramming. then a call to use here $generated_code; injects that code into the compiling source

sub my_0 {map "my \$$_ = 0", @_} # a simple macro

use here my_0 qw(x y z);

About Eric Strom (ASG)

user-pic https://metacpan.org/author/ASG