in reply to returning a tied variable

I think you've got no choice but to return a reference to the tied scalar. E.g.

tie $mod,'ModName',{blabla} ; return \$mod ;

If you're looking for an alternative, one would be to tie a scalar which is passed to the sub (by ref) rather than tying a lexical which is created in the sub. But I'm not suggesting that that's a better way to go.

We're building the house of the future together.

Replies are listed 'Best First'.
Re^2: returning a tied variable
by japhy (Canon) on Mar 01, 2006 at 16:06 UTC
    That's convenient. I was afraid that would simply return a reference to the return value of tied($mod)->FETCH, but it does indeed return a reference to the tied variable. Thanks, Perl!

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
Re^2: returning a tied variable
by jeanluca (Deacon) on Mar 01, 2006 at 16:00 UTC
    Thnx, So I can conclude that it is not possible to make a copy of a tied variable (or object)!?

    Luca

      You didn't say you wanted to make a copy. Of course it's possible. But to help you do that, I think I'd have to see more of the function in question, and also something about the TIE class you're using.

      We're building the house of the future together.