Re: stuck in a while loop



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;




.