Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

www::mechanize - the basics of a great perl module

by Perlbeginner1 (Scribe)
on Oct 25, 2010 at 22:53 UTC ( #867368=perlquestion: print w/replies, xml ) Need Help??

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


I'm trying to learn the basics of the mechanize module and i'm still very new to programming. Does anyone know of some good places to learn the very basics, say with some examples as well?

note - i found this example on
it is nice - indeed

use strict; $|++; use WWW::Mechanize; use File::Basename; my $m = WWW::Mechanize->new; $m->get(""); my @top_links = @{$m->links}; for my $top_link_num (0..$#top_links) { next unless $top_links[$top_link_num][0] =~ /^http:/; $m->follow_link( n=>$top_link_num ) or die "can't follow $top_ +link_num"; print $m->uri, "\n"; for my $image (grep m{^http://store4}, map $_->[0], @{$m->link +s}) { my $local = basename $image; print " $image...", $m->mirror($image, $local)->message, " +\n" } $m->back or die "can't go back"; }

this runs nice and gives a nice output!

Question: Does anybody have a even shorter example of mecha!?
i am looking for a short few-line-examplescript for Newbies

look forward

btw: Update: we also have For WWW::Machanize, cookbook for several more examples.

Replies are listed 'Best First'.
Re: www::mechanize - the basics of a great perl module
by morgon (Priest) on Oct 25, 2010 at 23:24 UTC
    use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get("", ':content_file' => "perlmonks.h +tml");
    There - one get only. Short enough?

    How to add error handling is covered in the documentation.

Re: www::mechanize - the basics of a great perl module
by sundialsvc4 (Abbot) on Oct 26, 2010 at 02:44 UTC

    Please be as specific as possible ... and don’t worry in the slightest about being “very new to programming.”

    Believe me... we have all “been there.”

      hi sunidalsvc4 / great to hear from you! mille grazie! many many thanks! i come back later! beginner1

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://867368]
Approved by aquarium
Front-paged by aquarium
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2021-11-28 02:52 GMT
Find Nodes?
    Voting Booth?

    No recent polls found