in reply to Re: regular expression for log file date ~ questions and ideas ~
in thread regular expression for log file date ~ questions and ideas ~

Thanks for the code...sorry about the slipup; I did mean equal to *not* greater than or equal to LOL. Now, I tried your code and it seems to work but what if my logfile was named something like filename-061201-randomnum-1293_log where the date is a bit before the _log and also some of my log names are similar but end in .log instead of _LOG. Anyway, your code got me thinking at least, thanks.
  • Comment on Re^2: regular expression for log file date ~ questions and ideas ~

Replies are listed 'Best First'.
Re^3: regular expression for log file date ~ questions and ideas ~
by Firefly258 (Beadle) on Dec 02, 2006 at 05:41 UTC
    Only you know what randomnum is, we can only assume it will be random and unpredictable. :)
    my $randomNum = getMyRandomNum(); my $directory = "/path/to/some/dir"; openddir DIR, $directory or die "opening $directory failed"; my $specialRegex = qr/$randomNum.*log$/i; my @logfiles = grep /$specialRegex/, readdir DIR; for my $logfile (@logfiles) { open LOG "<", $logfile or warn "...."; while (<LOG>) { print if dateMatches() .. 0; # should print all lines from where d +ateMatches() returns TRUE. ... } }


    perl -e '$,=$",$_=(split/\W/,$^X)[y[eval]]]+--$_],print+just,another,split,hack'er
      hmmm...where is your subroutine getMyRandomNum? Aside from that, some of your ideas look pretty helpful.
        getMyRandomNum() was for you to write :)


        perl -e '$,=$",$_=(split/\W/,$^X)[y[eval]]]+--$_],print+just,another,split,hack'er