Re: stuck in a while loop
- From: anno4000@xxxxxxxxxxxxxxxx
- Date: 30 Jun 2006 07:10:08 GMT
Nospam <nospam@xxxxxxxx> wrote in comp.lang.perl.misc:
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
The outer while loop will never end. There is no "last" statement (or
"goto", or whatever) that would leave it. The one "last" in the code
cuts off an inner loop after the first round, which doesn't make much
sense either. Probably the "last" is misplaced. There is too much
too messy code (left below for reference) to say anything more.
Anno
#! perl\bin\perl
use strict;
use warnings;
use Data::Dumper;
use WWW::Mechanize;
use LWP::Useragent;
open (FILE2, "text1.txt") or die "couldn't open $!";
use constant START => "<FILE2>";
while()
{
my $mech = WWW::Mechanize->new( );
my @url;
my $START = <FILE2>;
print "$START \n";
(my $varia1 = $START) =~ s/\@.*//;
print "$varia1 \n";
$mech->get('http://www.loginurl');
$mech->form(1);
$mech->field('login',"$varia1");
if ($mech->success){ print "login successfully set \n";} else{print $!;}
$mech->submit();
if ($mech->success){ print "login successfully submitted \n";} else{print
$!;}
$mech->follow_link( text_regex => qr/Daily news/i);
if ($mech->success){ print "link successfully followed \n";} else{print
$!;}
my ($content3) = $mech->content() =~ /= "(.*)r"/;
my @content1 = $content3;
foreach my $content2 (@content1) {
open (FILE, ">> hm5.txt");
print $content2."\n";
print FILE $content2."\n";
last;
}
}
close FILE2;
close FILE;
.
- References:
- stuck in a while loop
- From: Nospam
- stuck in a while loop
- Prev by Date: FAQ 4.69 How can I use a reference as a hash key?
- Next by Date: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.6 $)
- Previous by thread: stuck in a while loop
- Next by thread: Re: stuck in a while loop
- Index(es):