in reply to Re: Perl Hash Files
in thread Perl Hash Files
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{$_}++;
|
|---|