I need to set package variables in the package 'main' to the value of
a key with the same name. I thought the code below would do it:
sub globalize_weightframe {
my ($i)=@_;
warn "Globalize was passed $i.";
my %w = %{$hangar->{stops}[$i]{weightframe}};
for my $val (keys %w) {
eval "$main::$val = $w{$val}";
warn "globalize $val - $w{$val}";
}
}
but printing the value of one of the globals after calling this sub
does not yield anything, whereas it does in the warn right within this
sub.
Any help on setting a set of package variables in this way is appreciated.