in reply to counting lines in perl
What do you have so far? It's much easier to help you if we can see what you've done wrong.
You are aware that uniq only removes consecutive repeated lines, right? So the trick is to only keep track of the last line, and the count of the last line. If the current line is identical, increment the count, otherwise print it out with the count and set a new last line. The second trick is that when you're done with the file, you'll have a last line that isn't printed out, so you'll have to handle that, too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: counting lines in perl
by imhotep (Novice) on Feb 26, 2005 at 20:01 UTC | |
by Tanktalus (Canon) on Feb 26, 2005 at 20:41 UTC | |
by crashtest (Curate) on Feb 26, 2005 at 21:12 UTC | |
by imhotep (Novice) on Feb 26, 2005 at 22:24 UTC | |
by crashtest (Curate) on Feb 26, 2005 at 23:09 UTC | |
|