in reply to generating subroutines from array variables

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.