NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Cool (Score:1)
This is the second module in a week that has used PadWalker as a way of finding out the names of the variables that are passed to a function. I should probably make a robust way of doing that and ad
Re:Cool (Score:1)
Thankfully it is a little more robust than that - instead of assigning to the hash returned by PadWalker that hash is used as a reference to map parameters (i.e the lexicals passed to MAPARGS) to the named arguments. Simply assigning to the returned hash c
broquaint out
Re:Cool (Score:1)
I did look at the code, and I grok what it's doing (which is very cool). What I mean is that:
use Params::Named;
sub ick {
MAPARGS \my($foo, $bar);
print "Foo = $foo\n";
{my $foo}
}
ick(foo => 23)
will give the spurious error
The parameter '$foo' doesn't match argument type 'SCALAR'.The problem, of course, is that sub ick has more than one lexical called 'foo', and in this case peek_sub is returning the wrong one, so you don't
Re:Cool (Score:1)
broquaint out
Re:Cool (Score:1)
Check out the latest PadWalker beta [man.ac.uk], which has a new function called
var_name.Using that, you should also be able to make your module work from anonymous subs (which I assume it doesn't, at the moment).