It checks for the existence of a value and then increments if there is one.
> -----Original Message-----
> From: Cohan, Drew [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 07, 2001 10:46 AM
> To: [EMAIL PROTECTED]
> Subject: order of operations
>
>
> Hi,
>
> I don't understand something about Perl's order of operations
> with this
> code:
>
> ...if ($name_count{$member}++)...
>
> Does Perl retrieve the value for $name_count{$member},
> increase it by one,
> and then evaluate the if() statement? If that's true, then I don't
> understand how the else would ever fire.
>
> TIA,
>
> -- Drew.
>
>
> <code snippet>
>
> my @family = qw (drew john john mom dad vicki danny);
> my (@uniq, $member, %name_count);
>
> foreach $member ( @family ) {
> if ($name_count{$member}++) { # instead of unless on purpose
> #do nothing # anything other
> than 0 or undef
> is true
> } else {
> push(@uniq,"$member\n");
> }
> }
>
> foreach $member ( keys %name_count ) {
> print "$member: $name_count{$member}\n";
> }
>
> print "\n", (@uniq);
>
> </code snippet>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]