in reply to strict, typeglobs, and evaluation order
No, that's all fine. The reason strict doesn't care about this:
my $f = sub { print "a: ", a(), " b: ", b(), "\n";};
... is because you've used parentheses for the argument lists. This means that the sub calls are not syntactically considered barewords. use strict "subs" only cares about barewords.
I wouldn't necessarily consider it an especially elegant technique, but everything should work. Personally I'd at least try to clean up the subs that add_var installed at the end of mdo:
sub mdo { my @to_be_cleaned; while (scalar @_ > 1) { my $name = shift; my $fn = shift; add_var($name,$fn); push @to_be_cleaned, $name; } my $fn = shift; my $return = $fn->(); require namespace::clean; namespace::clean->clean_subroutines('main', @to_be_cleaned); return $return; }
|
|---|