sjlo has asked for the wisdom of the Perl Monks concerning the following question:
I'm pretty sure it's all good but I cant help but think that I screwed up somewhere with the syntax, could you guys point me in the right direction please? When I run it, it says Line 7 is a possible typo. Thanks -sjlo#!/usr/bin/perl -w use LWP::UserAgent; my $digits; open( FILE, "< /tmp/blah.txt" ) or die "Can't open $filename : $!"; while( <FILE> ) { $digits = $_; print "Attempting line: " . $digits; k_go_now($digits); # Sleep to keep us slightly more hidden and load off their servers sleep(1); } # k go now sub; grabs input from file ($username, $password) tries to +login sub k_go_now { my ($digits) = @_; $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); # Create a request my $req = HTTP::Request->new(POST => 'https://xxx'); $req->content_type('application/x-www-form-urlencoded'); $req->content('query=libwww-perl&mode=dist'); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { check_output ($res->content); } else { print $res->status_line, "\n"; } } # suib check_output checks the response from the website and if it's a +ny good sub check_output { my ($output) = @_; if ($output =~ /Login Failed/) { print "Nope, failed login\n"; } elsif ($output =~ /Login Successful/) { print "got'em with login details\n"; } else { print "unknown response !!!\n$output\n\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Where did I go wrong?
by ikegami (Patriarch) on Nov 13, 2007 at 22:26 UTC | |
by sjlo (Initiate) on Nov 13, 2007 at 22:29 UTC | |
by ikegami (Patriarch) on Nov 13, 2007 at 22:32 UTC | |
by sjlo (Initiate) on Nov 13, 2007 at 22:34 UTC | |
by ikegami (Patriarch) on Nov 13, 2007 at 22:35 UTC | |
|
Re: Where did I go wrong?
by holli (Abbot) on Nov 13, 2007 at 22:34 UTC | |
by sjlo (Initiate) on Nov 13, 2007 at 22:46 UTC | |
by andreas1234567 (Vicar) on Nov 14, 2007 at 06:29 UTC | |
by cdarke (Prior) on Nov 14, 2007 at 10:43 UTC | |
|
Re: Where did I go wrong?
by Fletch (Bishop) on Nov 13, 2007 at 22:21 UTC | |
|
Re: Where did I go wrong?
by toolic (Bishop) on Nov 13, 2007 at 22:24 UTC | |
by sjlo (Initiate) on Nov 13, 2007 at 22:27 UTC | |
by ikegami (Patriarch) on Nov 13, 2007 at 22:34 UTC |