procmail
[Top] [All Lists]

implemention right() function with procmail (efficiency)

1998-01-09 06:17:57

    I was reformatting my tips page and stopped for a while to the
    section where philip gave suggestions how to manipulate strings
    in procmail. I got curious what would be the cheapesp right()
    operation. (ref: "How to drop characters from a string")

    Can anyone comment: these both give identical results, but what
    is the preferred? What does it actually mean if I change SHELL
    in the middle of procmail code. If the latteris more efficient,
    then I would use it in spite of slightly more code needed.

    jari
    
VAR = "123"

SHELL = /bin/sh                         # --- CASE 1
ret = `expr "$VAR" : '\(.*\)..'`

saved = $SHELL                          # --- CASE 2
SHELL = /bin/ksh
ret   = `echo ${VAR%??} ;`  # semicolon to force invoking a shell
SHELL = $saved


--> ret will be "1"

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