in reply to Re: generating subroutines from array variables
in thread generating subroutines from array variables
Slight syntax correction to mattriff's cool code. You'll need to terminate the assignments with semicolons. (Well, this being Perl, you just need to separate them with semicolons, but let's pretend it's terminate so we don't run into problems the next time we add a statement).
my @list = qw/foo bar baz/; foreach my $element (@list) { *{$element} = sub { $state{$element} = 1; }; *{"${element}_"} = sub { $state{$element} = 0; }; }
-- Eric Hammond
|
|---|