use strict; use warnings; use Data::Rmap qw(:all); my $initial = [ note => [ shopping => [ 'item' ] ] ]; use Data::Dumper; my ($dump) = rmap_array { # If we get an arrayref whose first element is 'shopping' if ($_->[0] eq 'shopping') { my @item; # build a list of shopping items for my $item qw(bread butter beans) { push @item, [ item => $item ]; } # create a new array with those items my $newdata = [ shopping => \@item ]; # return immediately with new data, not visiting children # of this array cut($newdata) } else { # if the arrayrefs first element is not 'shopping' # then simply pass it through $_; } } $initial ; warn Dumper($initial, $dump);