Perl Mechanize - how to arrange the output in a concise order: [beginner-question]

hi dear Perl-friends

again me- well; i have started another thread since i have issues with
the ports. But that is another story:

first of all; i run linux opensuse 11.4 i try to run this little programme on a linux box.


#!/usr/bin/perl
    
    
    use WWW::Mechanize::Firefox;
    my $mech = WWW::Mechanize::Firefox->new();
    
    open(INPUT, "urls.txt") or die "Can't open file: $!";
    
    while (<INPUT>) {
      chomp;
      $mech->get($_);
      my $png = $mech->content_as_png();
    }
    close(INPUT);
    exit;

well i have a list of URLS: i have more than 1000 URLS - so it might be a problem if i get the results in a unsorted way.

i have a list of 1000 URLs, one on each line, saved in a file. then i want the script above to open the file, read a line, then retrieve the website! Well the URLS are stored something like this:

    Filename: urls.txt
    ------------------
    www.google.com
    www.cnn.com
    www.msnbc.com
    news.bbc.co.uk
    www.bing.com
    www.yahoo.com


question: how to write the script that the output of the thumbnail-images are stored with certain names - eg with the domain-names. How to do that!? Otherwise - the resuults would be a whole mess. I need to identify the thumbnails - related to the URLS. :Is this possible!?

love to hear from you

I’m not much of a perl guy, but since you already know the url, can’t you just concatenate it (or a portion thereof) onto $png?
(I’m sure there is a fancier way to do it directly through mechanize, but since you already know the url, seems like you could just do that.)

hello dear Lews

thx for the reply - i will try it out!

and i played around with the following

open my $out, ‘>’, “$.png" or die "could not open '$.png’ for output $!”;
print $out $png;
close $out;

Again: Note: i only need the screenshots - nothing more. Thats pretty easy -no scraping that goes into the deepnes of the site. Thank god it is that
easy!

greetings db1

so…did you end up solving this??

good day harvested

tx for the answer -

not solved yet. i had a short delay on workin on this…

But at the weekend i set up the os 12.1 and install perl and all that stuff.
afterwards Meachnize FireFox and then i come back here and report all my findings