procmail
[Top] [All Lists]

Re: how to drop last N characters from string?

1997-12-04 13:15:15
On 04 Dec 1997 15:21:25 +0200, <jari(_dot_)aalto(_at_)poboxes(_dot_)com> wrote:
        VAR = "1234567890"
        :0
        * VAR 123\/.*
        {
            rest = $MATCH
            Now I want to cop off "90" from $rest ?

There is no easy general way to accomplish this. Real backreference
grabs would be nice to have, but for now, your only option seems to be
to figure out a way to limit the match, or pass the result to sed for
finishing touches. 

    Also what's the procmail way to increment variable by N ?

Scoring is one way to do math:

    VAR=15

    :0
    * $ $VAR^0
    * $ $N^0
    { }
    VAR=$=

will assign 20 to VAR if N is 5.

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>