in reply to Re^4: Help Getting WWW::Mechanize Link reference array to output to STD_OUT.
in thread Help Getting WWW::Mechanize Link reference array to output to STD_OUT.
Yup, I meant to link to the Tutorials category Variables and Scoping
Function which don't take arguments are bad
Your original code perltidyd
How to write it so its coping with scoping :)
sub Main { my $mech = ...; ...; Get_Success( $mech ); ...; } sub Get_Success { my( $mech ) = @_; #prints the success result and starts a new line. print $mech->success(); print "\n"; }
Or better still, use the existing features of Mechanize
#!/usr/local/bin/perl -- use strict; use warnings; use WWW::Mechanize 1.72; Main( @ARGV ); exit( 0 ); sub Main { my $search = shift; my $mech = WWW::Mechanize->new( qw/ autocheck 1 show_progress 1 /); $mech->get( $search ); my @serverLinks = $mech->find_all_links( url_regex => qr/_css/i ); for my $link( @serverLinks ) { for my $member ( qw/ url text name tag / ){ no warnings 'uninitialized'; print $link->$member, "\n" ; } } } __END__ $ perl dumplinks http://nowhere.example.com ** GET http://nowhere.example.com ==> 500 Can't connect to nowhere.exa +mple.com:80 (Bad hostname) (1s) Error GETing http://nowhere.example.com: Can't connect to nowhere.exam +ple.com:80 (Bad hostname) at dumplinks line 15. $ perl dumplinks http://example.com ** GET http://example.com ==> 302 Found ** GET http://www.iana.org/domains/example/ ==> 200 OK /_css/2008.1/reset-fonts-grids.css link /_css/2008.1/screen.css link /_css/2008.1/print.css link
Also error is my $Input = ("LastName, FirstName"); you can see how if you use Basic debugging checklist
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Help Getting WWW::Mechanize Link reference array to output to STD_OUT.
by tfredett (Sexton) on Jul 05, 2012 at 15:35 UTC | |
by Anonymous Monk on Jul 05, 2012 at 16:30 UTC | |
by tfredett (Sexton) on Jul 06, 2012 at 14:03 UTC |