| Store | Cart

What is going on with this hash ++ ?!?!?

From: Mike Kangas <kan...@anlon.com>
Mon, 26 Jun 2000 17:36:20 -0500
I am ++'ing the value associated with $hash{"a"} but how
does this affect the $hash{"a"}->{Text} value?? I thought that the
end hash structure would look like this.

$hash{"a"} = 2;
$hash{"a"}->{Text} = "This is one";

$hash{"b"} = 3;
$hash{"b"}->{Text} = "This is two";

and output this....
a has val of ( 2 ) and text of 'This is one'
b has val of ( 3 ) and text of 'This is two'

...but it doesn't. Any help in understanding this would be greatly
appreciated.

#################################################

$hash{"a"} = 1;
$hash{"a"}->{Text} = "This is one";

$hash{"b"} = 2;
$hash{"b"}->{Text} = "This is two";

foreach $key (sort { $a cmp $b } keys %hash) {
   print "$key has val of ( $hash{$key} ) and text of
'$hash{$key}->{Text}'\n";
}
print "\n\n";

foreach $key (sort { $a cmp $b } keys %hash) {
   $hash{$key}++;
   print "$key has val of ( $hash{$key} ) and text of
'$hash{$key}->{Text}'\n";
}

####################################################

thanks.
mike kangas
kan...@anlon.com

Recent Messages in this Thread
Mike Kangas Jun 26, 2000 10:36 pm
Previous post: Re: MakeMaker problems
Next post: IPC - piped output