Catmandu::Fix::Bind::list(3pm)

Catmandu::Fix::Bind::list3pm

A binder that computes fix-es for every element in a list

Usage

     # Create an array:
     #  demo:
     #    - red
     #    - green
     #    - yellow
     # Add a foo field to every item in the demo list, by default all
     # fixes will be in context of the iterated path. If the context
     # is a list, then '.' will be the path of the temporary context
     # variable
     do list(path:demo)
        if all_equal(.,green)
            upcase(.)
        end
     end
     # This will result:
     #  demo:
     #    - red
     #    - GREEN
     #    - yellow
     # Loop over the list but store the values in a temporary 'c' variable
     # Use this c variable to copy the list to the root 'xyz' path
     do list(path:demo,var:c)
        copy_field(c,xyz.$append)
     end
     # This will result:
     #  demo:
     #    - red
     #    - GREEN
     #    - yellow
     #  xyz:
     #    - red
     #    - GREEN
     #    - yellow

Overview

The list binder will iterate over all the elements in a list and fixes the values in context of that list.

Configuration

path

The path to a list in the data.

var

The loop variable to be iterated over. When used, a magic temporary field will be available in the root of the record containing the iterated data.

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

From libcatmandu-perl 1.2024-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.