Perlbeginner1 has asked for the wisdom of the Perl Monks concerning the following question:

hello dear linux-fans -

well i run this script , which is written to do some screenshots of websites i have also up and running mozrepl

whats strange is the output - see below... question: should i do change the script why do i ge the output?



#!/usr/bin/perl 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); }




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 + + print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line + 13. + http://www.ph-solothurn.ch + + print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line + 14. + http://www.pfh-gr.ch + + print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line + 15. + http://www.ma-shp.luzern.phz.ch + + print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line + 16. http://www.heilpaedagogik.phbern.ch/ print() on closed filehandle OUTPUT at test_3.pl line 20, <INPUT> line + 17.

Replies are listed 'Best First'.
Re: strange output with Perl::mecha - seems to overload the machine
by Corion (Patriarch) on Mar 11, 2012 at 15:29 UTC

    First, there is no module Perl::mecha. It helps people to give you better answers if you put some effort into the title of your question. For example, a better title would have included the real module name in it.

    Second, in what sense do you mean "seems to overload the machine"? What symptoms did you witness that make you conclude "overloading of the machine"?

    Third, what steps have you taken to ensure that the problem is at all related to WWW::Mechanize::Firefox at all? If you don't know what a Perl warning means, use the diagnostics pragma to get more explanation:

    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. You need to do an open(), a sysopen(), or a so +cket() call, or call a constructor from the FileHandle package

    Alternatively, print() on closed filehandle OUTPUT also gives lots of answers that will tell you that you did not use autodie and also did not check the return value of open.

    A reply falls below the community's threshold of quality. You may see it by logging in.