1Data::Visitor::CallbackU(s3e)r Contributed Perl DocumentaDtaitoan::Visitor::Callback(3)
2
3
4

NAME

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

SYNOPSIS

9               use Data::Visitor::Callback;
10
11               my $v = Data::Visitor::Callback->new(
12                       value => sub { ... },
13                       array => sub { ... },
14               );
15
16               $v->visit( $some_perl_value );
17

DESCRIPTION

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

METHODS

23       new %opts, %callbacks
24           Construct a new visitor.
25
26           The options supported are:
27
28           ignore_return_values
29               When this is true (off by default) the return values from the
30               callbacks are ignored, thus disabling the fmapping behavior as
31               documented in Data::Visitor.
32
33               This is useful when you want to modify $_ directly
34

CALLBACKS

36       Use these keys for the corresponding callbacks.
37
38       The callback is in the form:
39
40               sub {
41                       my ( $visitor, $data ) = @_;
42
43                       # or you can use $_, it's aliased
44
45                       return $data; # or modified data
46               }
47
48       Within the callback $_ is aliased to the data, and this is also passed
49       in the parameter list.
50
51       Any method can also be used as a callback:
52
53               object => "visit_ref", # visit objects anyway
54
55       visit
56           Called for all values
57
58       value
59           Called for non objects, non container (hash, array, glob or scalar
60           ref) values.
61
62       ref_value
63           Called after "value", for references to regexes, globs and code.
64
65       plain_value
66           Called after "value" for non references.
67
68       object
69           Called for blessed objects.
70
71           Since "visit_object" in Data::Visitor will not recurse downwards
72           unless you delegate to "visit_ref", you can specify "visit_ref" as
73           the callback for "object" in order to enter objects.
74
75           It is reccomended that you specify the classes you want though,
76           instead of just visiting any object forcefully.
77
78       Some::Class
79           You can use any class name as a callback. This is clled only after
80           the "object" callback.
81
82       array
83           Called for array references.
84
85       hash
86           Called for hash references.
87
88       glob
89           Called for glob references.
90
91       scalar
92           Called for scalar references.
93

AUTHOR

95       Yuval Kogman <nothingmuch@woobling.org>
96
98               Copyright (c) 2006 Yuval Kogman. All rights reserved
99               This program is free software; you can redistribute
100               it and/or modify it under the same terms as Perl itself.
101
102
103
104perl v5.8.8                       2007-10-07        Data::Visitor::Callback(3)
Impressum