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.
|
|---|