good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: 2 dimensional array questionby reasonablekeith (Deacon) |
on Sep 05, 2005 at 13:58 UTC ( [id://489226]=note: print w/replies, xml ) | Need Help?? |
you need square brackets...
The square bracket returns a reference to an anonymous array. Your example is just a list, which is forced to scalar context (you're putting it into the first element of your array) which just returns the last element in your list. You can prove this by printing $arr[0]; You might also have noticed I changed the @'s to $'s, which it prefered when referencing a single element of an array... If you run your program with warnings on, it will tell you this. references are a big subject, you might want to check out ... or "Learing/Programming Perl" which are excellent books.
--- my name's not Keith, and I'm not reasonable.
In Section
Seekers of Perl Wisdom
|
|