my %ttys; for $line (`aml_read /l trace /h $_[3] /a commproc /s $_[1] /b $_[2] /d all`) { # I'm making this split up, you'll have to post the # format of aml_read or figure out the split yourself my ($something, $tty, $stuff) = split " ", $line; $ttys{$tty}++; } for my $tty (sort { $a <=> $b} keys %ttys) { print "Count for $tty: $ttys{$_}\n"; }