Difficult to give any specific help without knowing the
format of your data file, but let's assume that you have a
line with three pieces of data (url, name and hist count)
separated by colons. You could then do something like this:
open(DATA, 'hits.dat') or die "Can't open hits.dat: $!\n";
my @pages;
push @pages, [split /:/] while <DATA>;
my @sorted = sort { $b[2] <=> $a[2] } @pages;
@sorted now contains a list of your pages sorted from
highest to lowest hits. Each element contains a reference to
an array. Each of these second level arrays contains three
elements, the url, the name and the hit count. To display
a certain subset of these, you'd need to have a parameter
which tells you where in the list to start and you could
then use splice to extract the pages that you need.
Something like this perhaps:
my $start = param('start');
my $display = 20;
print map { "@$_\n" } splice @sorted, $start, $display);;
--
<http://www.dave.org.uk>
European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/> |