in reply to sorting arrays

A tip on your ksh script: uniq -c will do most of what you want:
sort modtype_2430.srt |uniq -c

In Perl, you can do something similar by sorting the array, then walking through it:

my @sorted = sort @array; my $last = shift @sorted; my $count = 1; foreach my $e (sort @array) { if ($last eq $e) { $count++; } else { print "$count\t$last\n"; $count=1; $last=$e; } } print "$count\t$last\n";

Or you can simply use a hash:

my %count; foreach my $e (@array) { $count{$e}++; } while (my($e,$count)=each(%count)) { print "$count\t$e\n"; }
(both of these are untested, but should give you a good general idea).