more useful options | |
PerlMonks |
Re: array index -1 oddityby Aristotle (Chancellor) |
on Dec 07, 2002 at 13:04 UTC ( [id://218241]=note: print w/replies, xml ) | Need Help?? |
If you really do need something like that (I'd think about that first), you can write it briefly as
$arr[@arr ? $#arr : 0] = $foo;
or maybe
(@arr ? $arr[-1] : $arr[0]) = $foo;
Makeshifts last the longest.
In Section
Seekers of Perl Wisdom
|
|