beast wrote:
>
> What is the reason this following works
> $hours{$hour}->{count} + 1
>
> but this not works?
> $hours{$hour}->{count}++
>
>
> it actually part of this code:
>
> $hours{$hour} = { occur => $occur_utc,
> delay => $hours{$hour}->{delay} + $delay,
> count => $hours{$hour}->{count} + 1
> };
Because the /value/ of
$hours{$hour}->{count}++
is the same as the value of
$hours{$hour}->{count}
It happens to have the side-effect of incrementing the value of the hash
element.
Note that it can be written more concisely as
$hours{$hour}{count}
(any pair of ]->[ or }->{ or a mixture of the two can have the indirection arrow
removed.)
I think you want
$hours{$hour} = {
occur => $occur_utc,
delay => $hours{$hour}{delay} + $delay,
count => ++$hours{$hour}{count},
};
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/