That can be more simply written as:if(exists $hash{$_}){ # exists, so increment $hash{$_}++; } else{ # doesn't exist, so set to 1 $hash{$_} = 1; }
But I think that the OP wants to increment the hash key instead of the value:$hash{$_}++;
$_++ while exists $hash{$_}; $hash{$_}++;
In reply to Re^2: Perl Hash Files
by jwkrahn
in thread Perl Hash Files
by blundell
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |