fans
Sorry for this newbie question, but I can't find on google what I need to know. I understand print , but don't understand this...
http://www.unifr.ch/sfm
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 2.
http://www.zug.phz.ch
see much much more below....
well - What does it mean this?
Thanks a lot for patience.
to begin with the beginning: well i run this script , which is written to do some screenshots of websites i have also up and running mozrepl here we have the file with some of the requested urls ... note this is only a short snippet of the real list - the real list is much much longer. it contains more than 3500 lines and URLs
http://www.unifr.ch/sfm
http://www.zug.phz.ch
http://www.schwyz.phz.ch
http://www.luzern.phz.ch
http://www.schwyz.phz.ch
http://www.phvs.ch
http://www.phtg.ch
http://www.phsg.ch
http://www.phsh.ch
http://www.phr.ch
http://www.hepfr.ch/
http://www.phbern.ch
http://www.ph-solothurn.ch
http://www.pfh-gr.ch
http://www.ma-shp.luzern.phz.ch
http://www.heilpaedagogik.phbern.ch/
whats strange is the output - see below... question: should i do change the script
why do i ge the output with the following little script:
use strict;
use warnings;
use WWW::Mechanize::Firefox;
my $mech = new WWW::Mechanize::Firefox();
open(INPUT, "<urls.txt") or die $!;
while (<INPUT>) {
chomp;
print "$_\n";
$mech->get($_);
my $png = $mech->content_as_png();
my $name = "$_";
$name =~s/^www\.//;
$name .= ".png";
open(OUTPUT, ">$name");
print OUTPUT $png;
sleep (5);
}
see here the well overwhelming output - to be frank i never have thught to get such a funny output .. i have to debug the whole code.... see below,
http://www.unifr.ch/sfm
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 2.
http://www.zug.phz.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 3.
http://www.schwyz.phz.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 4.
http://www.luzern.phz.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 5.
http://www.schwyz.phz.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 6.
http://www.phvs.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 7.
http://www.phtg.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 8.
http://www.phsg.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 9.
http://www.phsh.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 10.
http://www.phr.ch
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 11.
http://www.hepfr.ch/
print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line 12.
http://www.phbern.ch
well i have tried alot to get the errors rid
some musings: well -firstly, i think this is not a very serious error - i think i have to debug it and then it will work better.
Second, i firstly thought that the script seemed "to overload the machine"?
Now i am not very sure about that: the symptoms do look strange but i guess that it is not neecessary to conclude an "overloading of the machine"
Third, well i think of certain steps that have to be taken to ensure that the problem is at all related to WWW::Mechanize::Firefox at all?
This leads me to the point to what Perl warning means and to the idea to use the diagnostics pragma to get more explanation: what do you think?
print() on unopened filehandle FH at -e line 1 (#2) (W unopened) An I/O operation was attempted on a filehandle that w +as never initialized.
Well - we need to do an open(), a sysopen(), or a so +cket() call, or call a constructor from the FileHandle package
well - alternatively, print() on closed filehandle OUTPUT also gives lots of answers that will tell us that we did not use autodie and also did not check the return value of open. i have to debug it and make sure to find where the error comes into play
Sorry for this newbie question, but I can't find on google what I need to know. I understand print , but don't understand this...
Its an old Post but nevermind
I guess you do not have permission to write a file in the directory. So if you cannot Open a file handle the print()
cannot write to the file handle.
doing something like below might be more appropriate
open(OUTPUT, ">$name") or die "Cannot open file...\n";