in reply to Re^2: Data::Rmap to modify an arrayref of arrayrefs
in thread Data::Rmap to modify an arrayref of arrayrefs
The structure may not be right, but the sense is and I see your solution takes elements from my code so it wasn't all loss was it? You may find the following trivial variant more to your liking:
use strict; use warnings; use Data::Dump qw(); use Data::Rmap qw(); my $initial = [note => [shopping => ['item']]]; Data::Rmap::rmap_array { return $_ if $_->[0] ne 'shopping'; # Ignore non-shopping entries my @item= map {[item => $_]} qw(bread butter beans); $_ = ['shopping', @item]; Data::Rmap::cut ($_); } $initial; print Data::Dump::dump ($initial), "\n";
prints:
[ "note", [ "shopping", ["item", "bread"], ["item", "butter"], ["item", "beans"], ], ]
|
|---|