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

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

Well spotted Corion, and many thanks!

-M

Free your mind

Replies are listed 'Best First'.
Re^3: Code reference problem
by Moron (Curate) on Jan 04, 2007 at 15:57 UTC
    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}
        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

      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.