in reply to Re^2: Code reference problem
in thread Code reference problem

grrr!

I even got that wrong of course. The & shouldn't have a lower operator precedence than the actual parameter list ( $tref ), even though that compiles strangely enough. But when I use Corion's seemingly correct version, it won't compile :(

-M

Free your mind

Replies are listed 'Best First'.
Re^4: Code reference problem
by shmem (Chancellor) on Jan 04, 2007 at 16:19 UTC

    The ampersand is not needed. And

    if ( defined( my $coderef = $self -> { CALLBACK }{ ALL } ) ) { $coderef -> ( $tref );

    avoids deref clutter.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      At last!

      Following your suggestions I first had to refactorise it into this to avoid compilation error from redefining $coderef:

      my $coderef = $self -> { CALLBACK }{ ALL } || $self -> + { CALLBACK }{ TAG }{ $tag }; defined( $coderef ) and $coderef -> ( $tref );
      But as soon as I ran that the program worked as supposed to immediately. Thanks very much!

      -M

      Free your mind

Re^4: Code reference problem
by kwaping (Priest) on Jan 04, 2007 at 16:10 UTC
    Do you get any message from the compilation error? You might want to throw a use warnings in there as well.

    ---
    It's all fine and dandy until someone has to look at the code.