nikmit has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to assign values to variables like this:
The result is that within the foreach loop all is good, but outside of it the variables are empty... I tried to useforeach (@tagvalue) { if ($_ =~ /([\w,_]+):([0-9]+)/) { ${$1} = $2; } else { die "Failed to assign value to $1\n"; } }
but get an error on execution: 'Can't declare scalar dereference in "our"'.our ${$1} = $2;
./headbang
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Variable scope headaches
by jdporter (Paladin) on Jul 26, 2012 at 16:29 UTC | |
by nikmit (Sexton) on Jul 27, 2012 at 07:49 UTC |