Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: last 10 ... next 10?

by alfie (Pilgrim)
on Mar 28, 2001 at 11:13 UTC ( #67770=note: print w/replies, xml ) Need Help??

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 ;)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2022-05-18 03:08 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (68 votes). Check out past polls.