Data::Visitor::Callback(3pm) User Contributed Perl Documentation Data::Visitor::Callback(3pm)
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::Visitor.
This is useful when you want to modify $_ directly
tied_as_objects
Whether ot not to visit the "tied" in perlfunc of a tied structure instead of
pretending the structure is just a normal one.
See "visit_tied" in Data::Visitor.
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.
Any method can also be used as a callback:
object => "visit_ref", # visit objects anyway
visit
Called for all values
value
Called for non objects, non container (hash, array, glob or scalar ref) 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.
Since "visit_object" in Data::Visitor will not recurse downwards unless you delegate
to "visit_ref", you can specify "visit_ref" as the callback for "object" in order to
enter objects.
It is reccomended that you specify the classes (or base classes) you want though,
instead of just visiting any object forcefully.
Some::Class
You can use any class name as a callback. This is colled only after the "object"
callback.
If the object "isa" the class then the callback will fire.
These callbacks are called from least derived to most derived by comparing the
classes' "isa" at construction time.
object_no_class
Called for every object that did not have a class callback.
object_final
The last callback called for objects, useful if you want to post process the output of
any class callbacks.
array
Called for array references.
hash
Called for hash references.
glob
Called for glob references.
scalar
Called for scalar references.
tied
Called on the return value of "tied" for all tied containers. Also passes in the
variable as the second argument.
AUTHOR
Yuval Kogman <nothingmuch AT 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.
perl v5.10.0 2008-07-19 Data::Visitor::Callback(3pm)
Generated by $Id: phpMan.php,v 4.49 2006/02/26 13:18:18 chedong Exp $ Author: Che Dong
On Apache
Under GNU General Public License
2012-05-23 05:51 @38.107.179.236 Crawled by CCBot/1.0 (+http://www.commoncrawl.org/bot.html)