Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Printing the last few elements of an array.

by Molt (Chaplain)
on Dec 16, 2002 at 14:59 UTC ( [id://220221]=note: print w/replies, xml ) Need Help??


in reply to Printing the last few elements of an array.

You can, of course, merge the two approaches given above as demonstrated in this little piece of code here.

#!/usr/bin/perl use strict; use warnings; my @array = (1,2,3,4,5,6,7,8,9,10); print "$_\n" foreach @array[-3..-1];

I'd also like to thank rob_au and thinker since without seeing their posts next to one another I'd have not realised this nice simple way to do things- guess the random linking of ideas is one of the good things about this site. ++'s to both of you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://220221]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found