K
Kimi
Hi,
I am comparitively new to perl and so facing few issues with the
syntax. I have a log file whose contents are similar to
[Fri Nov 24 06:22:45 2006] Started instance Robo:4001
[Fri Nov 24 06:22:45 2006] Instance Robo:4002 is not running
[Sat Nov 25 06:22:46 2006] Started instance Robo:4002
[Sat Nov 25 06:22:46 2006] Instance Robo:4003 is not running
[Mon Nov 28 06:22:46 2006] Started instance Robo:4003
[Mon Nov 28 06:27:46 2006] Instance Robo:4000 is not running
[Wed Nov 30 06:27:46 2006] Started instance Robo:4000
[Wed Nov 30 06:29:46 2006] Instance Robo:4000 is not running
I am trying to extract the contents which holds true for the following
criteria
1. has the text "Started"
2. Date as specified in the regular expression
I have some general idea about regular expression, so i know that the
date in the above content can be matched using
/([A-Za-z]+)\s+([A-Za-z]+)\s+([0-9]+)\s+([0-9]+)[0-9]+)[0-9]+)\s+([0-9]+)/
But i am not clear how it can be used for the following case with perl
syntax.
I also would like to know if it is possible to use variable name for
pattern matching, say $day = Fri, being a variable $day will hold any
of the values between ( Mon, Tue, Wed, Fri, etc.. )
Can $day be used in regular expression?????
Any help is appreciable
regards,
Kimi
I am comparitively new to perl and so facing few issues with the
syntax. I have a log file whose contents are similar to
[Fri Nov 24 06:22:45 2006] Started instance Robo:4001
[Fri Nov 24 06:22:45 2006] Instance Robo:4002 is not running
[Sat Nov 25 06:22:46 2006] Started instance Robo:4002
[Sat Nov 25 06:22:46 2006] Instance Robo:4003 is not running
[Mon Nov 28 06:22:46 2006] Started instance Robo:4003
[Mon Nov 28 06:27:46 2006] Instance Robo:4000 is not running
[Wed Nov 30 06:27:46 2006] Started instance Robo:4000
[Wed Nov 30 06:29:46 2006] Instance Robo:4000 is not running
I am trying to extract the contents which holds true for the following
criteria
1. has the text "Started"
2. Date as specified in the regular expression
I have some general idea about regular expression, so i know that the
date in the above content can be matched using
/([A-Za-z]+)\s+([A-Za-z]+)\s+([0-9]+)\s+([0-9]+)[0-9]+)[0-9]+)\s+([0-9]+)/
But i am not clear how it can be used for the following case with perl
syntax.
I also would like to know if it is possible to use variable name for
pattern matching, say $day = Fri, being a variable $day will hold any
of the values between ( Mon, Tue, Wed, Fri, etc.. )
Can $day be used in regular expression?????
Any help is appreciable
regards,
Kimi