in reply to Array Searching

At the risk of xp--, but in the interest of being helpful, this is untested here, surely bug-filled, off the cuff, and written w/o consultation to any working code or documentation, so use at your own risk:
sub sitecounter { my @sites = @_; my(@sitepopularity); my($s,$site,@sitessorted,@validsites,@tmp); @sitessorted = sort @sites; foreach $site (@sitessorted){ push @validsites, $site unless $validsite[-1] eq $site; } foreach $site (@validsites){ foreach $s (@sites){ push @tmp $s if $site eq $s; } push @sitepopularity ($site, #@tmp); } return @sitepopularity; }
Of course it depends on how you define a site, should you add a subroutine to handle regex mangling to process the root domain, instead of the individual pages themselves, as this one does? But if you debug that, that ought to get you started.

Check out the docs for push, pop, sort, and if this was a homework question I helped you with, the caveats offered to new users here who ask others to do their homework for them.

-- Hugh

Replies are listed 'Best First'.
Re^2: Array Searching
by cptstarfire (Initiate) on Mar 10, 2006 at 10:22 UTC
    Thanks a lot for your help, another useful thing would be to show the amount of "hits", occurences the most popular sites have received.