in reply to Re: Re: Incrementing a Hash Value
in thread Incrementing a Hash Value

C specifically states this as undeifned. I think if perl did the same, your point would be valid.
From man perlop
    "++" and "--" work as in C.

Convinced?

Abigail

Replies are listed 'Best First'.
Re: Re: Incrementing a Hash Value
by Sifmole (Chaplain) on Jun 14, 2002 at 16:54 UTC
    No, because I can actually read perlop and find the following information right in the next paragraph.
    The auto-increment operator has a little extra builtin magic to it. If you increment a variable that is numeric, or that has ever been used in a numeric context, you get a normal increment. If, however, the variable has been used in only string contexts since it was set, and has a value that is not the empty string and matches the pattern `/^[a-zA-Z]*[0-9]*$/', the increment is done as a string, preserving each character within its range, with carry: print ++($foo = '99'); # prints '100' print ++($foo = 'a0'); # prints 'a1' print ++($foo = 'Az'); # prints 'Ba' print ++($foo = 'zz'); # prints 'aaa'
    And that certainly doesn't look like the behavior of any C compiler I ever worked with!

    So it works  as in C except obviously where it doesn't.

      Perhaps you should look up the meaning of extra in a dictionary.

      Abigail

Re: Re: Incrementing a Hash Value
by marvell (Pilgrim) on Jun 14, 2002 at 16:57 UTC
    That is, if placed before a variable, they increment or decrement the variable before returning the value, and if placed after, increment or decrement the variable after returning the value."

    I don't think that's in the same spirit, do you?

    --
    ¤ Steve Marvell