in reply to Re: counting lines in perl
in thread counting lines in perl

But that code doesn't seem to count groups of consecutive repetition just once, does it? - (which is what I thought the original poster wanted.)
chas
(Update: Actually, now that I've gone to a system where I could try out uniq -c, I see that I misunderstood what was desired so my code doesn't seem to do what the original poster wanted. Your code is closer, but the output isn't the same as that of uniq -c, at least the version I used. Sorry about the confusion...)

Replies are listed 'Best First'.
Re^3: counting lines in perl
by davidj (Priest) on Feb 27, 2005 at 13:42 UTC
    You are correct. My code is flawed. For some reason I thought uniq -c sorted the file first, but it doesn't. My mistake.

    davidj