in reply to sorting arrays

We can load the file into an array, loop through the array incrementing a hash using the entry as the key. Then loop through the hash sorted printing the value and the key.

use strict; use warnings; my @lines = <DATA>; chomp @lines; my $saw = {}; $saw->{$_}++ foreach @lines; print "$saw->{$_} = $_\n" foreach sort keys %$saw; __DATA__ a b va sdf b a v b n a h

Produces:

3 = a 3 = b 1 = h 1 = n 1 = sdf 1 = v 1 = va

___________
Eric Hodges