in reply to searching for multiple lines from outfile and printing them all in the final outfile
Also since it sounds like the output file doesn't have many lines in it, you may find it more convienent to finish writing it, close it, then open it for read, possibly just reading it all into memory at once. And do the search for what you want all at once rather than on a line by line basis as you go - this depends upon what you are looking for in the output.
I've got a number of gizmos that parse webpages, and often as another poster suggested, it is easier to do this in steps (eg, don't try to do it all with one regex). Do it in a couple of smaller steps.
Update: Oh another point, I see you are on Windows which allows spaces in the file names. You will save yourself a lot of grief if you start avoiding that feature. Your code will be more portable and you won't have to double quote the filename say in a type command on windows. Use an underscore _ perhaps like final_output.txt instead of the space.
my $output = $mech->content(); open(OUTFILE, ">", "$outfile"); print OUTFILE "$output"; open( FINAL, ">", "final output.txt" ); if ( $output=~ /(line i want )/ ) { print FINAL "$1"; } close FINAL;
|
|---|