The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Visitor::Callback - A Data::Visitor with callbacks.

SYNOPSIS

        use Data::Visitor::Callback;

        my $v = Data::Visitor::Callback->new(
                value => sub { ... },
                array => sub { ... },
        );

        $v->visit( $some_perl_value );

DESCRIPTION

This is a Data::Visitor subclass that lets you invoke callbacks instead of needing to subclass yourself.

METHODS

new %opts, %callbacks

Construct a new visitor.

The options supported are:

ignore_return_values

When this is true (off by default) the return values from the callbacks are ignored, thus disabling the fmapping behavior as documented in Data::Validator.

This is useful when you want to modify $_ directly

CALLBACKS

Use these keys for the corresponding callbacks.

The callback is in the form:

        sub {
                my ( $visitor, $data ) = @_;

                # or you can use $_, it's aliased

                return $data; # or modified data
        }

Within the callback $_ is aliased to the data, and this is also passed in the parameter list.

visit

Called for all values

value

Called for non objects, non aggregate (hash, array) values.

ref_value

Called after value, for references to regexes, globs and code.

plain_value

Called after value for non references.

object

Called for blessed objects.

array

Called for array references.

hash

Called for hash references.

AUTHOR

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT & LICENSE

        Copyright (c) 2006 Yuval Kogman. All rights reserved
        This program is free software; you can redistribute
        it and/or modify it under the same terms as Perl itself.