in reply to Re^2: using a string as a SCALAR ref while "strict refs" in use
in thread using a string as a SCALAR ref while "strict refs" in use
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
but that will only work of the vars are our varsno strict; if (defined $$newvarname) { $$var = $$newvarname; }
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 "; }
|
|---|