more useful options | |
PerlMonks |
Re: pushing a $variable into an array with varible nameby Ido (Hermit) |
on Jun 18, 2004 at 00:15 UTC ( [id://367809]=note: print w/replies, xml ) | Need Help?? |
You are trying to use symbolic refs. This is usually a bad idea (and you should always use strict to avoid it...), but in case you know what you're doing and insist: the expression: test-$number-$string Is like 'test' - $string - $number So, in all of the three push statements, you're pushing to the array @{-9} (strings are like 0 in numeral context, both 'vol1' and 'vol2', and the - operator implies numberal context). What you'd probably want to do is use them as strings, such as: @{"test-$contextID-$vol[0]"}
In Section
Seekers of Perl Wisdom
|
|