Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: What does 'next if $hash{$elem}++;' mean?

by inman (Curate)
on Feb 17, 2006 at 15:51 UTC ( #530980=note: print w/replies, xml ) Need Help??


in reply to Re^2: What does 'next if $hash{$elem}++;' mean?
in thread What does 'next if $hash{$elem}++;' mean?

It isn't necessary to do all of the intermediate processing. You can read a line and check it all at the same time.

The line is used as a hash key. The value is tested before being incremented and the line is added to the array.

my %seen; while (<PROCESSED_FILE>){ push @unique, $_ unless $seen{$_}++; }

This is OK if the hash doesn't grow to big. Using MD5 hashes of lines is an uesful technique.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://530980]
help
Chatterbox?
[Corion]: 1nickt: I imagine (heh) that Agile done somewhat right will make the process (and why we postpone things) somewhat more explicit to the outsider, or at least the "who do we ask to postpone X"

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2017-12-11 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (290 votes). Check out past polls.

    Notices?