Fwd: [Mastering-perl] First Peek: Tied Variables

brian d foy brian.d.foy at gmail.com
Thu Feb 9 12:47:47 EST 2006


On 2/8/06, Yitzchak Scott-Thoennes <sthoenna at efn.org> wrote:

> my $fh = \do {local *FH};
>
> (which does have the side-effect of creating a *FH symbol table entry,
> though $fh doesn't refer to it) or

okay, this works, but I have tothrown in the "no warnings" bit because
I only use that symbol name once. I do have to use a package cvariable
there (*FH), I do end up with a lexical variable.

    my $fh = \do{ no warnings; local *FH };
    my $object = tie *{$fh}, $class, $output_file;

I added a paragraph at the end of that secction showing this and
telling people not to do it. :)




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


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


More information about the Mastering-perl mailing list