Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The routine that later uses this reference is:sub setDestFile { my($self, $file) = @_; local(*F); open( F, ">$file"); $fh = \*F; $self->{'destfile'} = $fh; }
The above routine produces the following error when I try to run the program: String found where operator expected near "} "text"" (Missing operator before "$text"?) I tried to change the routine like this:sub output { my($self, $text) = @_; print $self->{'destfile'} "$text"; }
This change doesn't produce the error but nothing gets written to the file. HELPsub output { my($self, $text) = @_; my $fh = $self->{'destfile'}; print $fh "$text"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using File Reference
by danboo (Beadle) on Apr 05, 2002 at 16:57 UTC | |
|
(Ovid) Re: Using File Reference
by Ovid (Cardinal) on Apr 05, 2002 at 16:49 UTC | |
by Anonymous Monk on Apr 05, 2002 at 18:26 UTC | |
by danboo (Beadle) on Apr 05, 2002 at 20:29 UTC | |
|
Re: Using File Reference
by perlplexer (Hermit) on Apr 05, 2002 at 17:07 UTC |