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
I'm just not seeing how to implement the alternatives in my specific caseWell, its difficult to know, since you don't show why you need a bunch of $newfoo variables, but the approach with a hash might be to have two hashes, one for the original vars, and one for the new vars; so something like
use strict; my %vars = ("foo" => 1, "bar" => 2, "baz" =>3); my %newvars = ("newfoo" => "A"); foreach my $var (keys %vars) { my $newvarname = "new" . $var; if (defined $newvars{$newvarname}) { $vars{$var} = $newvars{$newvarname}; } }
Dave.
|
|---|