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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.