Catmandu::Fix::Bind::list - a binder that computes Fix-es for every element in a list
# Create an array: # demo: # - test: 1 # - test: 2 add_field(demo.$append.test,1) add_field(demo.$append.test,2) # Add a foo field to every item in the demo list, by default all # fixes will be in context of the iterated path do list(path:demo) add_field(foo,bar) end # Loop over the list but store the values in a temporary 'loop' variable # Use this loop variable to copy the list to the root 'xyz' path do list(path:demo,var:loop) copy_field(loop.test,xyz.$append) end # This will result: # demo: # - test: 1 # - test: 2 # xyz: # - 1 # - 2
The list binder will iterate over all the elements in a list and fixes the values in context of that list.
The path to a list in the data.
The loop variable to be iterated over. When used, a magic field will be available in the root of the record containing iterated data.
Catmandu::Fix::Bind
To install Catmandu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu
CPAN shell
perl -MCPAN -e shell install Catmandu
For more information on module installation, please visit the detailed CPAN module installation guide.