home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Perl CookbookPerl CookbookSearch this book

5.15. Finding the Most Common Anything

5.15.2. Solution

Use a hash to count how many times each element, key, or value appears:

%count = ( );
foreach $element (@ARRAY) {
    $count{$element}++;
}


Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.