(One could likely make this more brief at the expense of readability.)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"; }
In reply to Re: counting lines in perl
by chas
in thread counting lines in perl
by imhotep
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |