First of all, the hash is ALWAYS retrieved in a specific order, so we don't need to worry about that. I'm trying to get this to print the latest 20 images inserted into the DB on the first page (or page without a url_param) and apply a mathematical equation to figure out the proper range of each extra page.my $page = url_param('page'); my $top = $page* 20); my $bottom = $top - 20; if ($page ne "") { for ( grep defined($_), ( reverse keys %upload )[ $bottom .. $top ] ) +{ do this if url_param exists ... } else { for ( grep defined($_), (reverse keys %upload )[ 0 .. 19] ) { do this if on first page, without url_param ... }
I'm trying to accomplish something like:
page 1: latest 20 entries
page 2: 20 entries older than page 1
page 3: 20 entries older than page 2
page 4: 20 entries older than page 3
But the problem is, the equation isn't quite right because on some pages (other than the main page) it prints image 1 in it's range and on the next consecutive page it starts with image 1. It's using the same image on both pages.
Can anyone offer any advice?
In reply to mathematical equation by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |