[Mastering-perl] First Peek: Tied Variables

brian d foy brian.d.foy at gmail.com
Wed Feb 8 11:28:56 EST 2006


On 2/8/06, Yitzchak Scott-Thoennes <sthoenna at efn.org> wrote:
> On Tue, Feb 07, 2006 at 11:29:31PM -0600, brian d foy wrote:
> > I thought about tying just the {IO} portion of a scalar, but then I
> > need a package variable, which I think is worse than the
> > bareword. Oh well.

> Need a package variable?  For what?

> BTW, you can do

>   tie *{$fh}

how would that work, though? This code:

    my $fh;
    my $object = tie *{$fh}, $class, $output_file;

gives this error:

    Can't use an undefined value as a symbol reference

It seems to me that it's looking for something in the symbol table.
How would you get a globref otherwise?



--
brian d foy <brian.d.foy at gmail.com>
http://www.pair.com/~comdog/


More information about the Mastering-perl mailing list