Another option is to use the AUTOLOAD feature, and determine valid tag toggles using a hash rather than an array (although there's no reason you couldn't generate the former from the latter)...
my %state = ( name => 0, # default states gender => 0, address => 0, ); sub AUTOLOAD { my $tag = $AUTOLOAD; $tag =~ s/^.*:://; my $turn_off = $tag =~ s/_$//; # Only keep track of tags we want. return unless exists $state{$tag}; $state{$tag} = $turn_off ? 0 : 1; # Do something that uses %state whatever(); }
--k.
In reply to Re: generating subroutines from array variables
by Kanji
in thread generating subroutines from array variables
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |