in reply to counting lines in perl

If I understood what uniq -c is supposed to do, how about:
while (<>){ $i++; chomp; $lines[$i]=$_; $times{$lines[$i]}++ if $lines[$i] ne $lines[$i-1]; }; @keys = keys %times; @values = values %times; while (@keys) { print pop(@values), ': ', pop(@keys), "\n"; }
(One could likely make this more brief at the expense of readability.)
chas