use strict; use warnings; use Data::Rmap qw(:all); my $initial = [ note => [ shopping => [ 'item' ] ] ]; use Storable qw(dclone); my $clone = dclone $initial; use Data::Dumper; my ($dump) = rmap_all { if (ref and $_->[0] eq 'shopping') { my @item = map { [ item => $_ ] } qw(bread butter beans); warn Dumper(\@item); my $newdata = [ shopping => \@item ]; $_ = $newdata; } else { $_ = $_; } } $clone ; warn Dumper($initial, $dump);