Here is a pager method I'm using in Tk. Basically you put all the keys to be displayed into an @list, then you parse through @list pushing them into @{pager{$count}}, and incrementing $count when scalar @{pager{$count}} exceeds the desired pagesize.
###################################################################### +######## my $pagesize = 10; #elements per page sub setup_pager{ my $arrayref = $_[0]; #pass in @list my $new = $_[1]; #conditional for new %pager=(); #empty pager my $keytot = scalar @{$arrayref}; #print "$keytot\n"; my $key; #setup pages####################### my $count = 1; foreach $key (@{$arrayref}){ push @{$pager{$count}},$key; if(scalar @{$pager{$count}} > ($pagesize - 1) ){$count++} } ################################## if($new){&display_page($count)} else{ &display_page(1) }; } ###################################################################### +########## sub display_page{ $page = shift; my $e = shift || 1; #which entry to display, defaults to 1 #top is admin at 0 $pagetot = scalar(keys %pager); $pagerlab->configure(-text => "Page $page of $pagetot"); #blank previous thumbnail entries foreach(1..$pagesize){$h->hide('entry',$_)} #load page foreach my $key (@{$pager{$page}} ){ $ethumbs{$e}->blank; $ethumbs{$e}->read($info{$key}{'thumbnail'}); $h->itemConfigure ($e, 0, #image is read directly in Photo object above -text => $info{$key}{'comment'}, ); $h->itemConfigure($e, 1, -text => "$info{$key}{'name'}\n$info{$key}{'key'}", ); $h->show('entry',$e); $e++; } }

I'm not really a human, but I play one on earth. flash japh

In reply to Re: dividing a hash by sets of $num by zentara
in thread dividing a hash by sets of $num 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.