in reply to Re^2: print() on closed filehandle WRITE_FH
in thread print() on closed filehandle WRITE_FH

Probably because I've added your suggestions in the wrong place.

Yes, and pryrt already explained the issue. But then you posted here, so it seems like you didn't get it working?

If you take a look at the documentation I linked to, and the replies you've gotten, you'll see that:

If you go through your program line-by-line, the above information should be enough for you to see what is going wrong and how to fix it. If you have questions about the above, please always feel free to ask.

I understand the appeal of being able to copy and paste code and just have it work. However, I find it so much more satisfying to figure it out myself, to understand the flow of the code and what is going on. And of course, having it figured out means I'll know more about what I'm doing next time. In fact, I intentionally didn't post a block of code in an attempt to encourage you to look at the docs and figure it out :-)

Replies are listed 'Best First'.
Re^4: print() on closed filehandle WRITE_FH
by TonyNY (Beadle) on Oct 01, 2018 at 12:41 UTC

    Hi haukex, I was ale to get it to work by using OUT:

    #Parse html file using TreeBuilder Module use strict; use warnings; use HTML::TreeBuilder 3; #Open text file to redirect treebuilder output to file open OUT, '>', $treefile or die "cannot open $treefile for writing ; $!"; my $root = HTML::TreeBuilder->new; $root->parse_file($htmlfile) or die "could not open $htmlfile for pars +ing\n"; my @div_class = $root->find_by_attribute("class","forminput"); foreach my $node (@div_class) { print OUT $node->content_list(); print OUT "\n"; } close OUT;

    As far as just copying and pasting sometimes I an up against time constraints so I don't always have the time to fully understand the code and end up going back later to look at the code more closely which I will do with what you have provided for me here

      It’s great that you got it working. I caution against thinking this way: …I don't always have the time to fully understand…

      It is as likely—likelihood increasing with code size and complexity—to be false economy as it is to be true.