in reply to Unwanted cloning of array elements
$piece is a reference. You push the same reference onto your arrayref 3 times. It does not matter when or how you change some sub-part of the thing the reference points to. If you want 3 different elements in your arrayref then you are going to have to deep-copy $piece at every push.
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unwanted cloning of array elements
by oakbox (Chaplain) on May 07, 2021 at 10:37 UTC | |
by AnomalousMonk (Archbishop) on May 07, 2021 at 11:19 UTC |