in reply to Code reference problem

You got bitten by precedence:

&$self -> { CALLBACK }{ ALL } -> ( $tref );

deparses as

&{$self} -> { CALLBACK }{ ALL } -> ( $tref );

What you want is:

$self-> { CALLBACK }{ ALL } -> ( $tref );

or

&{ $self-> { CALLBACK }{ ALL } }( $tref );

Replies are listed 'Best First'.
Re^2: Code reference problem
by Moron (Curate) on Jan 04, 2007 at 15:08 UTC
    or even &{ $self-> { CALLBACK }{ ALL } }( $tref ) );

    Well spotted Corion, and many thanks!

    -M

    Free your mind

      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

        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}
        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.