Here's some code:
#!/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";
This fails with the following error:
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""
Now, if i change the code a little bit, it works fine:
my $fh = $self->{'fh'}; print $fh "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):
print scalar($self->{'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?

BlueLines

Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.

In reply to Bug (or feature) in 5.0053 print? by BlueLines

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.