I am trying to get this sample code that I found on a site to work:
#!/usr/bin/perl
use v5.10;
use WWW::Mechanize;
use WWW::Mechanize::TreeBuilder;
my $mech = WWW::Mechanize->new;
WWW::Mechanize::TreeBuilder->meta->apply($mech);
$mech->get( 'http://htmlparsing.com/' );
# Find all <h1> tags
my @list = $mech->find('h1');
# or this way
# Now just iterate and process
foreach (@list) {
say $_->as_text();
}
When I run it I get this message:
Can't locate WWW/Mechanize.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at test2.pl line 4.
BEGIN failed--compilation aborted at test2.pl line 4.
Does anyone have any ideas on what is happening?