If it's true that the contents of "$outpage" include a string that matches this regular expression:my $mech = WWW::Mechanize->new(); $mech->get($url); $mech->form_name('loginform'); $mech->field(login => $username); $mech->field(passwd => $password); $mech->click(); my $outpage = $mech->content(); open(OUTFILE, ">$outfile"); print OUTFILE "$outpage";
Then you just need four more statements: match and capture that string in $outpage, open your "final" output file, write the captured string to the output file, and close the file. If you need to see the code for that.../You have \d+ unread messages/
If that regex doesn't match, you'll need to check the actual contents of "$outpage", and figure out how the regex would need to change in order to match the desired phrase.if ( $outpage =~ /(You have \d+ unread messages)/ ) { open( FINAL, ">", "make_up_a_file_name" ) or die $!; print FINAL $1,"\n"; close FINAL; }
In reply to Re: Searching for a string in outfile
by graff
in thread Searching for a string in outfile
by ysksai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |