Are these date functions of perl part of the normal distribution or a CPAN module?

if (m|\Q$date\U|)


This didn't seem to make a difference.

I noticed a couple of commands that may help. System and exec. Apparently they were further in the Learning Perl book (I cheated.. flipped ahead ::grinz::)

If there is a perl function that will populate a variable with today's date please let me know. I'll try the system/exec commands and cross my fingers :D

Thx

Randy W. Sims wrote:

On 12/26/2003 5:39 PM, u235sentinel wrote:

While I've already done this with a simple shell script using grep, I was trying to figure out how I can do the same thing in perl.

I have an access_log from my apache web server and while I can manually enter a date for my pattern match (which works fine), I can't seem to get it automated properly. I suspect the $date variable may be passing `date +%d/%b` instead of 26/Dec to the pattern matching if statement.
FYI... when I run the program I pass the name of the file I want parsed ( example: code.pl access_log )


Any thoughts on my mistake?

Thx

---------------------

Script I'm using.

#!/usr/bin/perl

$date=`date +%d/%b`;


You could use perl's date functions for this.

 print "\n";
 print "Current search pattern is $date";
 print "\nStarting parse routine...\n\n";
 while (<>) {
   if (m|$date|) {


Any time you get a string you want to match from an external source, you should probably quote it:

if (m|\Q$date\U|) {


     print $_;
  } else {
 #  print "No match.\n";
  }
}








--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to