in reply to At each change in...

If you want to detect change from one line to another, indeed something like if $foo ne $previousfoo will do.

But detecting the first occurrence of a chain is quite another problem that can be solved by memorizing the number of occurences as value associated to the string:

perl -ne 'chomp; print "new $_\n" unless $a{$_}++' nm_of_processed_fi +le
The loop may have to be explicit depending on the source of your data.

-- stefp -- check out TeXmacs wiki