tuakilan has asked for the wisdom of the Perl Monks concerning the following question:
This is continued from http://www.perlmonks.org/?node_id=668491
i patched the following code provided by svenXY into the server:
when i try to run the program, it vomited out the following error:#!/usr/local/bin/perl -w use strict; use warnings; use DateTime::Format::Strptime; my $Strp = new DateTime::Format::Strptime(pattern => '%Y-%b-%d %T' +,); my $infile = 'logfile.2008-02-25.log'; my $outfile = 'report-2008-02-25.txt'; my($fh_out, $fh); my %lookup; my $channel = 'two'; my $time_delta = 3600; # seconds = 1 hour open($fh_out, '>', $outfile) or die "Could not open outfile: $!"; # open($fh, '<', $infile) or die "Could not open logfile: $!"; while (<DATA>) { next unless /$channel/; $_ =~ m/^(.*) UTC.*refs = (\d+)$/; my $dt = $Strp->parse_datetime($1); my $timestamp = $dt->epoch(); my $refs = $2; if ( defined($lookup{$refs}) && $lookup{$refs} + $time_delta <= $t +imestamp ) { print $fh_out "REFS $refs: occurrences at " . $lookup{$refs} . + "and $timestamp \n"; print "REFS $refs: occurrences at " . $lookup{$refs} . " and $ +timestamp \n"; } $lookup{$refs} = $timestamp; } close $fh_out; #close $fh;
The logfile.txt looks like thisName "main::DATA" used only once: possible typo at a3.pl line 24. readline() on unopened filehandle DATA at a3.pl line 24.
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 =
any clue on how to fix this ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need help on unopened file handle
by McDarren (Abbot) on Feb 28, 2008 at 06:48 UTC | |
|
Re: need help on unopened file handle
by ikegami (Patriarch) on Feb 28, 2008 at 07:11 UTC | |
|
Re: need help on unopened file handle
by munni (Novice) on Feb 28, 2008 at 07:21 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |