procmail
[Top] [All Lists]

Re: multiply by -1

2005-07-07 08:19:01
Ruud H.G. van Tol schreef:

      :0
      * VAR ?? ^^-?0*\/(0^^|[1-9][0-9]*)
      *$ $VAR ^ 0
      { VAR = "-$=" }
      :0E
      *$ $MATCH ^ 0
      { VAR = "$=" }
      :0E
      { VAR = 'zero' }


This variant also works with values like '-999999999999' 

      :0
      * VAR ?? ^^-?0*\/(0^^|[1-9][0-9]*)
      *$ $VAR ^ 0
      { VAR = "-$MATCH" }
      :0E
      *$ 0$MATCH ^ 0
      { VAR = "$MATCH" }
      :0E
      { VAR = 'zero' }

The '0$MATCH' prevents a log-line when MATCH is empty.

-- 
Grtz, Ruud

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>