in reply to Re^6: Checking LInes in Text File
in thread Checking LInes in Text File
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Checking LInes in Text File
by ibeneedinghelp (Initiate) on Jun 05, 2006 at 23:11 UTC |