November 2011 Archives

Introducing Begin::Declare

While working on a module for source code injection, one of my example "macros" was one that allows you to declare and assign to a lexical variable at compile time, without having to write the variable names twice. That concept more or less hijacked the conversation, and after some prodding from p5p to make the interface better, I've used Devel::Declare to add two new keywords to Perl, MY and OUR.

Here is the synopsis from the module:

don't you hate writing:
my ($foo, @bar);
BEGIN {
    ($foo, @bar) = ('fooval', 1 .. 10);
}
when you should be a…

About Eric Strom (ASG)

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