First of all, the hash is ALWAYS retrieved in a specific order, so we don't need to worry about that.

I'm worried about that. Why will it ALWAYS return in the correct order? Is it a special tied hash or something? If not, then the order may as well be random. In fact in perl5.8.1, for security reasons, the order is going to different every time you run the code.

Anyway, one thing that strikes me is that your range is funny. If $page = 2, then $top = 40 and $bottom = 20, which will give you 21 items per page. So I think you want to do

my $top = ($page * 20) - 1; my $bottom = $top - 19;
and then, rather than having a special case for $page="" you could write the whole thing as
my $page = url_param('page'); $page = 1 if $page eq ""; # fixup $page my $top = $page* 20 - 1; my $bottom = $top - 19; for ( grep defined($_), ( reverse keys %upload )[ $bottom .. $top ] ) { do this if url_param exists ... }

That said, I don't think there's anything in the above that would fix the symptoms you've described...


In reply to Re: mathematical equation by fergal
in thread mathematical equation by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.