in reply to Re: Wierd Behavior With Tie
in thread Wierd Behavior With Tie

TMTOWTDI, for sure. On the other hand, the pit bull in me has my teeth into tying variables, and I want to find some way to make it work. Closest I've been able to come so far is this wrapper, which fixes the issue:

print call $tied, 5; sub call(@){ my $tied = shift; return $tied->(@_); }


I hate the look of that, though. I really want to be able to tie the scalar, and call the routine via

print $tied->(5), $/;

Replies are listed 'Best First'.
Re^3: Wierd Behavior With Tie
by ikegami (Patriarch) on Jun 02, 2006 at 19:40 UTC

    On the other hand, the pit bull in me has my teeth into tying variables

    Tied variables are pretty slow, and they don't always work due to bugs. That's why I suggested the alternative.

    Closest I've been able to come so far is this wrapper

    The variable you called $tied isn't tied. That's why it works. If you fix the variable name, you get:

    sub call { my $sub = shift; return $sub->(@_); }

    You basically took the solution I already posted and put it in a function.

    I got rid of the misleading/broken/wrong prototype. Don't use prototypes unless you have a good reason and you understand the problems associated with using them.

      Credit where credit's due, I took a look at my implementation, plus Limbic~Region's fix, and by the time I had everything working I was implementing your sub inside a tied variable.

      Goodbye, tie.

      Thanks for the comments and suggestions.