Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: A C-like brain in a Perl-like world

by Aristotle (Chancellor)
on Sep 28, 2001 at 14:54 UTC ( [id://115363]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: A C-like brain in a Perl-like world
in thread A C-like brain in a Perl-like world

The key is that $uniq{$_} does not exist the first time a specific $_ is seen. Because it is preincremented, its value becomes 1. Then it is tested against == 1, and well, that is true. The next time that $_ is seen, $uniq{$_} already has a value of 1 or higher, so after the preincrement it becomes 2 or higher, then fails the == 1 test and is therefor dropped by grep. Thus, only the first appearance of a certain $_ makes it into the final list.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://115363]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found