in reply to Re: Re: Link Tracker
in thread Link Tracker

I didn't test this out but I was wondering if you could increment both the key and value at the same time? $db{$var1}++ = ++$value;

(1) If you are using incremental values as hash keys, then you should probably be using a plain array instead.

(2) Yes, you can increment the array index (or key) and the value in one statement. The correct way would be: $db[$index++] = ++$value (or similarly with a hash key, if you insist), whereas your initial guess (with "++" outside the brackets) is not allowed; it generates a compile-time error.

Go ahead, try it yourself and see. Your guess is "logically" equivalent to:  $j++ = ++$i (I'm glad perl treats this as an uncompilable coding error).