#!/usr/bin/perl my @buckets = (); my $highest = 0; while (<>) { /^.\s+(\d+)\s+/ or next; $buckets[$1]++; if ($1 > $highest) { $highest = $1; } } for my $i (0..$highest) { my $count = $buckets[$i]; $count ||= 0; print "$i $count\n"; }