On Aug 23, Rob Waggoner said:
>while ($line = <LOGFILE>) {
> $line =~ /\[(.+)\] /; # get date time value between []
> $ThisDateTime = $1; # should look like 19/Aug/2001:06:28:45 -0600
>
> # this works
> #($ThisDate, $Junk) = split(/:/, $ThisDateTime);
>
> # this is more elegant? Turn 19/Aug/2001:06:28:45 -0600 into
>19/Aug/2001
> $ThisDateTime =~ / (^.*?:) /; # is this pattern bad?
> $ThisDate = $1; # or does $1 need to be 'reset'?
Your whitespace is killing the regex. The regex
/ ^/
can never match -- there can never be ANYTHING BEFORE the beginning of the
line.
Also, the $DIGIT variables are not set to undef on a failed match -- they
retain their previous values.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]