BlueLines has asked for the wisdom of the Perl Monks concerning the following question:
This fails with the following error:#!/usr/bin/perl -wT use strict; open (FOO, '>/tmp/foobar') or die "Couldn't open /tmp/foo: $!\n"; my $self = { 'fh' => \*FOO}; print $self->{'fh'} "This is a test\n";
Now, if i change the code a little bit, it works fine:String found where operator expected at ./foo.pl line 5, near "} "Thi +s is a test\n"" (Missing operator before "This is a test\n"?) syntax error at ./foo.pl line 5, near "} "This is a test\n""
Why? I thought that $self->{'fh'} wasn't being intepreted in the correct context. So i even tried this (which failed as well):my $fh = $self->{'fh'}; print $fh "This is a test\n";
Why is this? I realize that filehandle references are easier to deal with in 5.6, but we use 5.0053 at work, and there's no way we're switching anytime soon. So is this a known bug, or am i totally missing something?print scalar($self->{'fh'}) "This is a test\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bug (or feature) in 5.0053 print?
by bikeNomad (Priest) on Jul 27, 2001 at 04:54 UTC | |
|
Re: Bug (or feature) in 5.0053 print?
by petral (Curate) on Jul 27, 2001 at 05:22 UTC | |
|
Re: Bug (or feature) in 5.0053 print?
by bwana147 (Pilgrim) on Jul 27, 2001 at 12:07 UTC |