Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by jerrygarciuh (Curate)
on Sep 28, 2001 at 00:58 UTC ( [id://115258]=note: print w/replies, xml ) Need Help??


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

What is the incrementation doing there? Is it moving
through the keys of %uniq to see if $_ is a match?
TIA,
jg
  • Comment on Re: Re: A C-like brain in a Perl-like world

Replies are listed 'Best First'.
Re^3: A C-like brain in a Perl-like world
by Aristotle (Chancellor) on Sep 28, 2001 at 14:54 UTC
    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://115258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found