[Classiccity-pm] perl curiosity..

Paul Keck pkeck at uga.edu
Thu Aug 5 09:35:41 CDT 2004


On Thu, Aug 05, 2004 at 10:29:29AM -0400, Darrell Golliher wrote:
> 
>   So I'm reading someone elses code and come acrosse something like
>   this..
> 
>     @things = qw(one two three);
>     print $things[-1];

print $things[$#things];

which I find even uglier.

It wouldn't help in this case, but depending on the situation you could just
pop off the last element for some purpose, if the array were disposable.

$whatever = pop @things;


-- 
Paul Keck       pkeck at uga.edu         http://www.arches.uga.edu/~pkeck
University of Georgia                 http://www.uga.edu/ucns/telecom
EITS Network Engineering              mailto:pkeck at ediacara.org
    --Opinions mine.--                Go fighting anomalocaridids!!!


More information about the Classiccity-pm mailing list