Values & References9 / 18
Up next

Mutate through a ref

use strict;
use warnings;
use feature 'say';

# pass an array ref so the sub can edit the original
sub add_one {
    my ($aref) = @_;
    push @{ $aref }, 1;
}
my @data = (0);
add_one(\@data);
say "@data";   # 0 1
What you're solving

a sub edits the caller's array