in reply to How to read a text file, extract a records that contains a string, export the result into a temporary file

Hi,
your example makes it harder as necessary...
Besides, it does not actually do something. I'd assume it doesn't even compile properly.
Here's a working example (opening/closing the logfile is here replaced by reading from the DATA handle):
use strict; use warnings; my $infile = 'b2bclient-gateway-heartbeat.log'; my $outfile = 'results.txt'; my($fh_out, $fh); open($fh_out, '>', $outfile) or die "Could not open outfile: $!"; # open($fh, '<', $infile) or die "Could not open logfile: $!"; # while (<$fh>) { while (<DATA>) { /TWO/ && print $fh_out $_; } close $fh_out; #close $fh; __DATA__ 2007-Nov-07 00:00:00 UTC (GMT +0000) - Poll: channel = ONE, ref = 2007-Nov-07 00:00:01 UTC (GMT +0000) - Poll: channel = TWO, ref = 2007-Nov-07 00:00:01 UTC (GMT +0000) - Poll: channel = TWO, ref = 2007-Nov-07 00:00:02 UTC (GMT +0000) - Poll: channel = THREE, ref = 2007-Nov-07 00:00:02 UTC (GMT +0000) - Poll: channel = TWO, ref = 2007-Nov-07 00:00:03 UTC (GMT +0000) - Poll: channel = TWO, ref = 2007-Nov-07 00:00:03 UTC (GMT +0000) - Poll: channel = TWO, ref = 2007-Nov-07 00:00:04 UTC (GMT +0000) - Poll: channel = TWO, ref =

Regards,
svenXY
  • Comment on Re: How to read a text file, extract a records that contains a string, export the result into a temporary file
  • Download Code

Replies are listed 'Best First'.