in reply to Pulling by regex II
In many cases it's often better to make a big regex for the entire line. A fully-expanded line-matching regex can break out all the variables you need without any leftover material that needs to be stripped off with substitutions.my %month = ( Jan => 0, Feb => 1, ... ); # ... $month = $month{$month}; # Could stand to use better names
open(LOGFILE, "datafile.html") || die "Can't open file";Further, you can actually iterate over the log file one line at a time instead of reading it all in:
By the way, that commented out #use strict; is scary. The reason you're getting errors is because you're not properly declaring your variables with my. For example:foreach my $log_line (<LOGFILE>) { # ... }
my $hour = param ("hour"); my $minute = param ("minute");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Pulling by regex II
by JayBonci (Curate) on Dec 14, 2002 at 06:49 UTC | |
by BrowserUk (Patriarch) on Dec 14, 2002 at 08:12 UTC | |
by JayBonci (Curate) on Dec 14, 2002 at 08:25 UTC | |
by BrowserUk (Patriarch) on Dec 14, 2002 at 08:31 UTC | |
by tadman (Prior) on Dec 14, 2002 at 20:10 UTC | |
by BrowserUk (Patriarch) on Dec 14, 2002 at 20:19 UTC | |
|
Re: Re: Pulling by regex II
by mkent (Acolyte) on Dec 14, 2002 at 22:51 UTC | |
by tadman (Prior) on Dec 14, 2002 at 23:26 UTC |