Not sure if this will help you at this point, but I strongly recommend the
Date::Manip module for anything involving parsing dates. It does everything you can
imagine with dates and more. Tell it to parse your dates, and boom you can print
them however you want, get differences, etc. There are plenty of other date mods on
CPAN as well, but I've used Date::Manip and can say that it is awesome. Check it
out.


--- Craig Moynes/Markham/IBM <[EMAIL PROTECTED]> wrote:
> Continuing with the problems for my 'date formatting' script.
> 
> I am reading in a complete record from a logfile.  I check to see if the
> regexp matches to something inside the record.
> Then I want to find the what each grouped mini-regexp matched up with in
> the monster one at the bottom of the email.
> 
> The number of mini-regexp differs depending on the date format line the
> user enters.  So i find out how make keys there are (thus the number of
> mini-regexps)
> and try to construct a string that will print out whatever the mini-regexp
> matched up with.  But of course it doesn't work ;)
> 
> <snip>
> $completeRec = "[Wed Aug  2 16:00:02 2000] [notice] caught SIGTERM,
> shutting down";
>  my $numOfKeys = keys %{$self->{DF_TOKENS}};
> for ( $counter = 1; $counter < $numOfKeys; $counter++)
> {
>      $replaceString.="\$$counter ";
> }
> my $values = $completeRec;
> 
> $values =~ s/.*$self->{DF_REGEXP}.*/$replaceString/g;
> print "$values\n";
> 
> <code done>
> 
> Where $self->{DF_REGEXP} = something like :
> (?-xism:((?-xism:Mon|Tue|Wed|Thu|Fri|Sat|Sun))) (?-xism:((?
> -xism:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))) (?-xism:((?-xism:
> [ ][1-9]|[1-2][0-9]|3[0-1]))) (?-xism:((?-xism:[01][0-9]|2[0-3]))):(?-xism:
> ((?-xism:[0-5][0-9]))):(?-xism:((?-xism:[0-5][0-9]))) (?-xism:((?
> -xism:[0-9]{4})))
> 
> 
> This prints out something like:
> $1 $2 $3 $4 $5
> 
> for each record.  Which is not to useful ;)
> 
> However if I change the "$replaceString" to $1 $2 $3 etc it works
> perfectly.
> So what are my options guys and gals ?
> 
> 
> -----------------------------------------
> Craig Moynes
> Internship Student
> netCC Development
> IBM Global Services, Canada
> Tel: (905) 316-3486
> [EMAIL PROTECTED]
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to