Re: stuck in a while loop
- From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 10:00:56 +0200
Nospam schreef:
Can anyone identify what is wrong with code, or worse how to fix it?,
it worked one time, but not anymore, I have hardly made any changes
#! perl\bin\perl
Does that work? I mainly reformatted:
#!/usr/bin/perl
use strict ;
use warnings ;
use Data::Dumper ;
use WWW::Mechanize ;
use LWP::Useragent ;
my $in = 'text1.txt' ;
my $out = 'hm5.txt' ;
open my $fh_in, '<', $in or die "Error opening $in: $!" ;
open my $fh_out, '>>', $out or die "Error opening $out: $!" ;
while ( <$fh_in> )
{
local $\ = "\n" ;
my $mech = new WWW::Mechanize ;
print ;
s/\@.*// ;
print ;
$mech->get('http://www.loginurl') ;
$mech->form(1) ;
$mech->field('login', $_) ;
print $mech->success
? 'login successfully set'
: "login set failed: $!" ;
$mech->submit() ;
print $mech->success
? 'login successfully submitted'
: "login submit failed: $!" ;
$mech->follow_link( text_regex => qr/Daily news/i ) ;
if ($mech->success)
{
print 'link successfully followed' ;
my ($content) = $mech->content() =~ /= "(.*)r"/ ;
print "\n----\n${content}\n----" ;
print $fh_out $content ;
}
else
{
print "link follow failed: $!" ;
}
}
close $fh_out or die "Error closing $out: $!" ;
close $fh_in or die "Error closing $in: $!" ;
(untested)
--
Affijn, Ruud
"Gewoon is een tijger."
.
- References:
- stuck in a while loop
- From: Nospam
- stuck in a while loop
- Prev by Date: Re: Professional IDE for a cross-platform Perl application
- Next by Date: Re: Question on printerhandling
- Previous by thread: Re: stuck in a while loop
- Next by thread: Re: stuck in a while loop
- Index(es):
Relevant Pages
|