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.