Re: stuck in a while loop



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."


.



Relevant Pages

  • Re: remove directory from @INC
    ... use DBI; ... use strict; ... use warnings; ... No errors are given anymore in the editor. ...
    (perl.beginners)
  • Re: Testing 123
    ... His filters are pretty strict for posting, ... google posts are automatically filtered out so you won't see them ... reason left to write anything anymore. ...
    (rec.motorcycles.dirt)
  • Re: Testing 123
    ... His filters are pretty strict for posting, ... google posts are automatically filtered out so you won't see them ... reason left to write anything anymore. ...
    (rec.motorcycles.dirt)