On Thu, Mar 22, 2012 at 01:08:53PM -0700, Leo Susanto wrote:
> you should do
> 
> print {$hdl} "a line\n";
> 
> instead of
> 
> print $hdl "a line\n";

Why?

> On Thu, Mar 22, 2012 at 1:06 PM, Chris Stinemetz
> <[email protected]> wrote:
> > On Thu, Mar 22, 2012 at 2:47 PM, Manfred Lotz <[email protected]> wrote:
> >> Hi all,
> >> If I run the following small test snippet
> >>
> >> <--------------------------------------snip------------>
> >> #! /usr/bin/perl
> >>
> >> use strict;
> >> use warnings;
> >>
> >> use autodie;
> >>
> >>
> >>
> >> open my $hdl, ">", "fileio1.txt";
> >> print $hdl "a line\n";
> >> close $hdl;
> >>
> >> open HDL, ">", "fileio2.txt";
> >> print HDL "a line\n";
> >> close HDL;
> >> <--------------------------------------snap------------>
> >>
> >>
> >> I get the message:
> >> Name "main::HDL" used only once: possible typo at ./fileio1.pl line 16.

This bug appears to have been fixed in perl 5.12.0 and later.  Since
5.10 and earlier versions are officially unsupported you should really
upgrade if you can.  With the imminent release of 5.16, 5.12 will
shortly become unsupported.

> > It looks like you are tyring to open two different filehandles. You
> > need to delcare HDL.
> > open my $HDL, '>', "fileio2.txt";
> >
> > should fix it.

No, it won't.

-- 
Paul Johnson - [email protected]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to