in reply to Re^2: technique of push
in thread technique of push
I said it was a prototype. You could have searched the docs for "prototype" :-( They're documented in perlsub.
As for 0+@$ref, it adds zero to the value to which @$ref evaluates. Keep in mind that the addition operator imposes a scalar context on its operands. perldata says "If you evaluate an array in scalar context, it returns the length of the array." Zero plus the length of the array is the length of the array.
Since push returns the length of the resulting array, I made my_push return the same thing.
(Without the 0+, @$ref would be evaluated in the same context as the my_push call, and could result in the wrong value being returned.)
|
|---|