Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

storing issue: script stores not at the intended place

by Perlbeginner1 (Scribe)
on Mar 29, 2012 at 18:29 UTC ( #962452=perlquestion: print w/ replies, xml ) Need Help??
Perlbeginner1 has asked for the wisdom of the Perl Monks concerning the following question:

good day dear monks

this is a question regarding a storing issue - the main part of a little mecha-script works well - i want to store the results in a directory - so that the gathered fiels do not mess up my machine... so here we go... with the outline and the question... look forward to hear from you

i need to have some thumbnails from websites but i tried to use wget - but that does not work for me, since i need some rendering functions what is needet: i have a list of 2,500 URLs, one on each line, saved in a file. Then i want a script - see it below - to open the file, read a line, then retrieve the website and save the image as a small thumbnail. well since i have a bunch of web-sites (2500) i have to make up my mind about the naming of the results.

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


So far so good, well i think i try something like this

use strict; use warnings; use WWW::Mechanize::Firefox; my $mech = new WWW::Mechanize::Firefox(); open my $urls, '<', 'urls.txt' or die $!; while (<$urls>) { chomp; next unless /^http/i; print "$_\n"; $mech->get($_); my $png = $mech->content_as_png; my $name = $_; $name =~ s#^http://##i; $name =~ s#/##g; $name =~ s/\s+\z//; $name =~ s/\A\s+//; $name =~ s/^www\.//; $name .= ".png"; open my $out, ">", $name or die $!; binmode $out; print $out $png; close $out; sleep 5; }


Note: all is nice and runs well so far untill - yes untill i tried to create a special option: i wanted to force the script to do some storing of the results in a folder Well, what do you think about the idea of storing the results in a folder called images or so!?) is this doable? it would help alot since i get stored the results in a folder. And the many results do not mess the machine...

i run into some issues. tried to do it - to store it in a directory thusly:

should i do it like so....

open(my $out, '>', "path/$name")
To write a file whose name is contained in $name in the directory images, the correct syntax is
<br> <br> open(my $out, '>', "images/$name")
note - the directory called images is in the very same folder...

i get the results

perl test_8.pl Global symbol "$images" requires explicit package name at test_8.pl li +ne 23. Execution of test_8.pl aborted due to compilation errors. martin@linux-wyee:~/perl> martin@linux-wyee:~/perl> perl test_8.pl Bareword found where operator expected at test_8.pl line 23, near "$/i +mages" (Missing operator before images?) syntax error at test_8.pl line 23, near "$/images " Global symbol "$out" requires explicit package name at test_8.pl line +24. Execution of test_8.pl aborted due to compilation errors. martin@linux-wyee:~/perl> perl test_8.pl Bareword found where operator expected at test_8.pl line 23, near "$/i +mages" (Missing operator before images?) syntax error at test_8.pl line 23, near "$/images " Global symbol "$out" requires explicit package name at test_8.pl line +24. Execution of test_8.pl aborted due to compilation errors. martin@linux-wyee:~/perl> martin@linux-wyee:~/perl> perl test_8.pl Bareword found where operator expected at test_8.pl line 23, near "$ " +images" (Missing operator before images?) String found where operator expected at test_8.pl line 23, at end of l +ine (Missing semicolon on previous line?) syntax error at test_8.pl line 23, near "$ "images" Can't find string terminator '"' anywhere before EOF at test_8.pl line + 23. martin@linux-wyee:~/perl>



Any opinions on the best path forward?

Comment on storing issue: script stores not at the intended place
Select or Download Code
Re: storing issue: script stores not at the intended place
by Anonymous Monk on Mar 29, 2012 at 18:55 UTC
      hello deaar anon- i will take all your advices and try out all the implementations of "use-strict-warnings" etc. etx. many many thanks for the answer - the help and your patience... greetings
Re: storing issue: script stores not at the intended place
by marto (Chancellor) on Mar 29, 2012 at 19:41 UTC

    "Any opinions on the best path forward?"

    You've been posting problems relating to this task since December last year. You have consistently failed to take peoples advice, you have failed to learn from your mistakes, you have pretty consistently failed to provide the code which you're running (the error message for $images you display here is impossible to generate from the code posted). You've been advised many times on these issues both in reply posts and in CB discussions. Either you're not interested in learning how to do this yourself, or you're not capable. If you just want this to work, pay someone to do if for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://962452]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-07-13 21:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (252 votes), past polls