> and, as someone pointed out, this does work: > $x = ['abc','def','ghi']; > print @$x[2]."\n"; # prints 'ghi'
Am I alone in thinking that $x->[2] is much more readable that @$x[2] or $$x[2]? > > but i couldn't tell you how perl reads this, except to say that '@$x' > dereferences and then '[2]' gets the array element. > but i don't know why a '$' isn't needed to tell perl you want the > scalar value of that element. @$x[2] works the same way that if you have @b = ('abc','def','ghi'); print "@b[2] == $b[2]\n"; @b[2] is an array slice with a single element (which strangely seems to get auto-cast as a scalar). > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > // George Schlossnagle // Principal Consultant // OmniTI, Inc http://www.omniti.com // (c) 240.460.5234 (e) [EMAIL PROTECTED] // 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]