in reply to Re: Re: hash keys, %
in thread hash keys, %

splice(@keys, 0, 20) removes the first 20 items from the array @keys, but almost as important, it also returns the items it removed. So it's like using shift on a larger chunk. You can use splice to simulate push, pop, shift, and unshift, as well as insert and remove items from the middle of an array. Of course, the man page for splice goes over all this in detail, but it's often useful to think of a splice operation in terms of those 4 basic list operators.

But I would suggest not even using this loop, since you never actually seem to use the stuff in @group that you splice off. You only seem to be interested in the number to print out, so you could just as easily do this:

use POSIX 'ceil'; my $url = "http://..."; my $num_pages = ceil( (keys %hash) / 20 ); print qq(<a href="$url?page=$_">$_</a><br>\n) for 1 .. $num_pages;
Even if you do use this method, you should still get familiar with splice!

blokhead