PERL based log analyzer
SourceForge.net Logo
Home Home Contact us Contacts
Overview Documentation Downloads Contacts Links
 
News & Updates
 
July 21, 2008
v 1.0 now available
Quick Links
 
Sourceforge project's page
CeCILL license
CEA web site
The 'Let' statement. Operation available on variables next up previous contents
Next: Using a 'Let' statement Up: Using the variables Previous: Caller's environment variables   Contents

The 'Let' statement. Operation available on variables

Each time a event, order or action is matched or a pattern is found, it is possible to modify the value of the variables. This operation is always done after the operation implicated by the use of the object are done. For example, if an event is realized, the operation on the variable is made just after the verification of all the combo lines. To associate the realization of an object with an operation on variable, an additional keyword was introduced: the 'Let' keyword. The argument of this keyword is a string enclosed with '{' and '}' and using a regular, semicolon separated variable syntax. Again, I think that a few short examples are better than a long explanation:

I want to put the value 3 to $(myvar1) :

 Let = { $(myvar) <- 3 ; }
I want to put the value 3 to $(myvar1) and to put 4 to $(my_other_var) :
 Let = { $(myvar) <- 3 , $my_other_var <-4 ; }
I want to put $(var) plus $(var2) in $(my_var):
 Let = { $(my_var) <- $(var1) + $(var2) ;}
I want every numerical character to disappear from variable $(my_var):
  Let = { $(myvar) <-~ s/(\d+)//g ; }
I want to increment a counter called $(cpt):
 Let = { $(cpt) +<- 1 ;}

As I said before, the 'Let' keyword is just to be added to a 'Order', 'Action', 'Event' or 'Pattern' definition, for example:

Pattern: Name = MyPattern ; Log = MyLog ; \
	RegExp=Something; Let = { $(my_var) <- 0 ;} ;

You can use let to modify several variables in the same 'Let' statement, but you must used the comma ``,'' as a separator to each operation. For example:

Pattern: Name = MyPattern ; Log = MyLog ; \
	RegExp=Something; \
	Let = { $(a) <- 2 , $(b) +<- 3 , $(c) <- $(d) + 4 ;} ;



Subsections
next up previous contents
Next: Using a 'Let' statement Up: Using the variables Previous: Caller's environment variables   Contents
Philippe Deniel 2008-07-22
Designed by CMG Technologies, adapted by Thomas LEIBOVICI
Design downloaded from Free Templates