$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.
🦛
In reply to Re: Unwanted cloning of array elements
by hippo
in thread Unwanted cloning of array elements
by oakbox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |