in reply to last 10 ... next 10?

There are several approaches that you can use. If you are using an SQL database for the backend there is the LIMIT command where you can select exactly just the lines you want, with offset and length. Please take a look at the documentation of the database, then...
This has also the advantage that it saves lots of memory and is quite possibly faster.

If you want to do it in perl and/or don't know if your database supports the LIMIT selection, you should try with slices of the aray:

@foo = ("1", "2", "3", "4", "5", "6", "7", "8"); print "@foo[3..6]\n";
This gives you the wanted elements. Don't forget that you start counting with 0 for the first element (so this returns the 4th to the 6th element). Thanks to alakaboo and his great explenation in this note :-)

Until you don't go further into detail about the layout of your database or how you proceed your data within your perl script I can't offer better answer (maybe other more enlighened monks can ;)
--
Alfie