I've got a horribly complex nested data structure, which isn't working...
Early on in my object I create an array of passed-in objects by pushing them onto the array like this:
(Each element in the array is an array of two elements.)
sub add_log { my ($self, $parser, $coderef) = @_; push @{$log_list{refaddr $self}}, [ $parser, $coderef ]; return 1; }
A little later on I'm trying to use a method in that object like this:
sub find_message { my ($self, $argref) = @_; # Parse the arguments, and get all the message info. my $msg_info = $self->_parse_args($argref, 1); # The '1' means +throw an error if we don't have any info. # Find the message in the first log. if ($log_list{refaddr $self}->[0][0]->find_message_info($msg_info) +) { # Do something. return 1; } else { return 0; } }
Finally, I've got the following test script:
my $tracer = Mail::Log::Trace::Postfix->new({log_file => 't/data/lo +g'}); my $object = Mail::Log::Trace::Multiple->new(); $object->add_log( $tracer, sub {} ); my $condition = {to_address => '<0001@example.com>', from_start => +1}; ok($object->find_message($condition) , 'Mail::Log::Trace::Multiple: + Find message from "to" field.'); ok($tracer->find_message_info($condition), 'tracer test.');
Which fails the first test but not the second. So I know the method works. (And it wouldn't compile at all if I wasn't calling it correctly: I've tested that by changing the spelling.)
So I am absolutely sure the problem is that the line $log_list{refaddr $self}->[0][0]->find_message_info($msg_info) is mis-behaving. How it's mis-behaving I'm not so sure about. (As far as I can tell, it's operating as a no-op.)
Anyone have any ideas on how to get that line to correctly function? Or what I'm doing wrong?
- DStaal
In reply to Calling a subroutine via multiple dereferences. by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |