Data::Visitor::Callback - A Data::Visitor with callbacks.
use Data::Visitor::Callback; my $v = Data::Visitor::Callback->new( value => sub { ... }, array => sub { ... }, ); $v->visit( $some_perl_value );
This is a Data::Visitor subclass that lets you invoke callbacks instead of needing to subclass yourself.
Construct a new visitor.
The options supported are:
When this is true (off by default) the return values from the callbacks are ignored, thus disabling the fmapping behavior as documented in Data::Visitor.
This is useful when you want to modify $_ directly
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.
Called for all values
Called for non objects, non container (hash, array, glob or scalar ref) values.
Called after value, for references to regexes, globs and code.
value
Called after value for non references.
Called for blessed objects.
You can use any class name as a clalback. This is clled only after the object callback.
object
Called for array references.
Called for hash references.
Called for glob references.
Called for scalar references.
Yuval Kogman <nothingmuch@woobling.org>
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.
To install Data::Visitor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Visitor
CPAN shell
perl -MCPAN -e shell install Data::Visitor
For more information on module installation, please visit the detailed CPAN module installation guide.