thx. Shawn that fixed the issue.


________________________________
From: Shawn H Corey <shawnhco...@gmail.com>
To: beginners@perl.org
Sent: Wednesday, September 14, 2011 8:40 PM
Subject: Re: error print on closed file handle

On 11-09-14 08:38 PM, Rajeev Prasad wrote:
> plz. advice why am i getting this error?
> 
> 
> I have checked:
> varilable outfile has proper path/filename
> array allrecords has data
> 
> 
> open(OUT_FH,">","$outfile");
> print OUT_FH "@allrecords";
> close OUT_FH;

# You should test all your opens; your problem probably lies there.
# You shouldn't stringify the file name.
# You should use lexical file handles.

  open my $out_fh, '>', $outfile or die "could not open $outFile: $!\n";
  print $out_fh "@allrecords" or die "could not print to $outfile: $!\n";
  close $out_fh or die "could not close $outfile: $!\n";


-- Just my 0.00000002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

"Make something worthwhile."  -- Dear Hunter

-- To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/

Reply via email to