in reply to Re: incrementing a column
in thread incrementing a column

In your one liner ITYM if( $_ ne $last ) { $i++; $last = $_ }.