in reply to Re: Scalars tied to logfiles
in thread Scalars tied to logfiles

You don't need to define an UNTIE method for untie($var) to work. If you don't, it just un-sets the flag on the tied scalar, and reduces the reference count on the tie object.

$h=$ENV{HOME};my@q=split/\n\n/,`cat $h/.quotes`;$s="$h/." ."signature";$t=`cat $s`;print$t,"\n",$q[rand($#q)],"\n";

Replies are listed 'Best First'.
Re: Re: Re: Scalars tied to logfiles
by duff (Parson) on Dec 11, 2003 at 05:31 UTC

    Aye, but he'll probably want to close the filehandle on untie.

      Good observation... you made me think it through for a minute.

      I think that because I'm using an object-oriented approach to the file handling (IO::File), when the scalar is either UNTIEd or DESTROYed the IO::File object will have its ref-count dropped down to zero, and the file will be closed automatically.


      Dave