At 04:25 PM 6/18/01 -0400, Brett W. McCoy wrote:
>On Mon, 18 Jun 2001, Paul wrote:
>
> > > > I am having trouble understanding just what the following does,
> > > > and how to you use it:
> > > >
> > > > $hash{$_}++
> > > >
> > > > i.e. are we increment the value or the key?
> > >
> > > The value. If you wanted to increment the key, you would say
> > > "$hash{$key++}".
> >
> > Wait a sec, brain cramp....
> > Wouldn't that:
> > 1) just access $hash{$key}
> > 2) increment $key
> > 3) add $hash{$key + 1}
>
>Ya kow, I saw that when I sent it. I think ++$key would be more
>appropriate.
No, that would:
1. Increment $key
2. Access $hash{$key} # new $key
You can't change a key in a hash. You can only access its value, or delete it.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com