in reply to Why does $$self++ works?
Why is it possible to use an object as a counter?
You are not using the object as a counter but the de-reference of the object. $self is the object but it's also a reference to a scalar (since that's how you have constructed it). When you de-reference the object therefore you get a scalar and so $$self++ is incrementing the scalar. Since the example you mentioned starts with $active = 0, that's the value from which you will be incrementing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why does $$self++ work?
by ikegami (Patriarch) on Sep 29, 2018 at 07:14 UTC | |
|
Re^2: Why does $$self++ work?
by rob25 (Initiate) on Sep 28, 2018 at 10:10 UTC |