Well because I really don't want to turn strict off... strict is lexically scoped, you don't have to turn it off for the whole program
no strict;
if (defined $$newvarname) {
$$var = $$newvarname;
}
but that will only work of the vars are our vars
I'm just not seeing how to implement the alternatives in my specific case.
You could improve upon your description ( post a more complete question), I don't see why a hash couldn't work
my %hash = ( qw/ foo 1 bar 2 baz 3 / );
$array[$user_section] =~ s{
^ username => (.*) $
}{
Dance( \%hash, $1 );
}xemg;
sub Dance {
my( $vars, $one ) = @_;
my $name = $vars->{$one};
return "username => $name" if defined $name;
die "no name for $one ";
}
|