It counts the number of occurances of all lines in a file until a directive BREAK.
---- a v b a a BREAK ----- Then, $seen{a} = 3; $seen{v} = 1; $seen{b} = 1; On 8/11/07, Todd Beverly <[EMAIL PROTECTED]> wrote: > > Mark Funk wrote: > > What exactly does the following Perl code do? > > > > %hash=(); > > > > open(PREVFILE, $prevfile) or die("Unable to open previous file"); > > > > while(<PREVFILE>) { > > chomp; > > last if /BREAK/; > > $seen{$_}++; > > } > > close(PREVFILE); > > > > > At the end of the loop, The %seen hash keys will have every unique line > in $prevfile, up to a line that has 'BREAK' in it. The values of the > hashes will contain the number of times that a line occurs. One way to > look for duplicate lines in a file. > _______________________________________________ > Perl-Win32-Users mailing list > Perl-Win32-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs >
_______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs