Skip Menu |

This queue is for tickets about the Data-Visitor CPAN distribution.

Report information
The Basics
Id: 38306
Status: resolved
Priority: 0/
Queue: Data-Visitor

Owner: Nobody in particular
Requestors: wdhawes [...] (daily)

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.18

Subject: Return value from callback always ignored
Download (untitled) / with headers
text/plain 1.3k contains the following: sub { my ( $visitor, $data ) = @_; # or you can use $_, it's aliased return $data; # or modified data } That implies that returning a value from a callback sub replaces the original value referenced by $data, but that's not the behaviour I'm seeing: #!/usr/bin/perl use strict; use warnings; use Data::Visitor::Callback; use Data::Dumper; my $data = { action => 'original' }; my $callbacks = { value => sub { my( $visitor, $data ) = @_; # program gets to here and $data eq 'original' return 'modified'; } }; my $v = Data::Visitor::Callback->new( %$callbacks ); $v->visit( $data ); print Dumper $data; The above program prints: $VAR1 = { 'action' => 'original' }; If I alter "return 'modified';" to either of the following: s/$data/modified/; $_ = 'modified'; Then I get the output I expected first time around: $VAR1 = { 'action' => 'modified' }; I've noticed that there's a constructor option called ignore_return_values, but this is documented as being set to 0 by default and dumping $v confirms this is the case here. I'm not sure if this is a bug, a documentation issue, a misunderstanding on my part about how this module is supposed to work, or a combination of the three.
Download (untitled) / with headers
text/plain 274b
Hi, Sorry for missing this bug, I will release 0.21 shortly. When the value was not a reference the original was returned errorniously. Note that the "value" and "plain_value" callbacks are also called for hash keys, so make sure you don't map those by accident. Cheers

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to