in reply to Re: creating 2 file writing objects
in thread creating 2 file writing objects

Many thanks to you ... and the others who replied so quickly, for pointing out the error of my ways which stems in part I think from trying to write Java in Perl. I could just use a cpan module, but I had the feeling that I was misunderstanding something fundamental that I needed to sort out. Next on my list is to re-read perltoot. Meanwhile ... one more question if I may, I'm trying to
print $self->{file_handle} "some text \n" ;
which is wrong, but can't figure out what it should be. Thanks again

Replies are listed 'Best First'.
Re: Re: Re: creating 2 file writing objects
by postman (Acolyte) on Jun 27, 2002 at 20:01 UTC
    On top of my OO confusion, I was getting led further astray by my overlooking the global nature of filehandles, and my mistaken way of trying to store them in a hash. Got there in the end ... by storing a reference to the file handle in a hash
    use FileHandle; my $FH = FileHandle->new(">>$self->{output_file}"); $self->{file_handle} = \$FH;
    and used in other methods like this
    my $FH = ${$self->{file_handle}}; print $FH "some text\n" ;
    Thanks again for all the pointers.