Man pages sections > man3 > Catmandu::Fix::perlcode

Catmandu::Fix::perlcode - execute Perl code as fix function

Catmandu::Fix::perlcode(3pm) User Contributed Perl Documentation Catmandu::Fix::perlcode(3pm)


Catmandu::Fix::perlcode - execute Perl code as fix function


Use this fix in the Catmandu fix language to make use of a Perl script:
The script (here "") must return a code reference:
    sub {
        my $data = shift;
        return $data;
When not using the fix language this
    my $fixer = Catmandu::Fix->new( fixes => [ do '' ] );
    $fixer->fix( $item );
is roughly equivalent to:
    my $code = do '';
    $item = $code->( $item )
All scripts are cached based on their filename, so using this fix multiple times will only load each given script once.
The code reference gets passed a second value to reject selected items such as possible with see Catmandu::Fix::reject:
    sub {
        my ($data, $reject) = @_;
        return rejection_criteria($data) ? $reject : $data;
To indicate the end processing, return "undef".


Catmandu::Fix::code, Catmandu::Fix::cmd
2017-10-01 perl v5.26.0