Just in case there is some confusion or misunderstanding of some of the Perl tricks used I better go through some of that code and elaborate on what's happening. Note that I've taken interesting lines in processing order rather that the order they are coded.
$firstLines{$data} = @lines;this is a little tricksy. It creates a new entry in %firstLines that contains the index to the new line as the value and is keyed by the unique part of the line contents. @lines in scalar context returns the number of elements in the array.
if (exists $firstLines{$data})checks to see if we've already seen a specific line.
$lines[$firstLines{$data}] .= ", $type";builds the multiple entries for duplicated lines. Note that $firstLines{$data} returns the index number that was stored earlier.
In reply to Re^7: Checking LInes in Text File
by GrandFather
in thread Checking LInes in Text File
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |