in reply to perl functionality like unix's "sort -u" and "uniq -c"
and uniq -c is pretty muchmy %hash = map {($_ => undef)} <>; print sort keys %hash;
More complete implementations of Unix tools in Perl are available from CPAN as PPT::Util.my $prev=<>; my $count=1; while (<>) { if ($prev eq $_) { $count++ } else { printf "%4d %s", $count, $prev; $count = 1; $prev = $_; } } printf "%4d %s", $count, $prev;
|
|---|