procmail
[Top] [All Lists]

Re: A tip (was: Reversing text?)

2002-05-14 06:39:18
Udi wrote,

| I note from the FAQ and from this list that we try to avoid echos
| or double pipes for performance reasons.    Maybe it will helps,
| by using awk(1) you can pass input as argument and work around IO
| handling.  The following example reverse the text in MATCH with
| no need for echo or IO redirect:
|
| awk 'BEGIN{NF=split(O,T,".");for(i=NF;i;i--)N=N"/"T[i];print N;exit}'
O=$MATCH

That's a very good idea!  (Having no formal training in this stuff, I didn't
know that.)  That gets rid of the need to pipe echo to another process that
needs the string as stdin.

A further improvement: save $SHELLMETAS in another variable (if you haven't
already) and unset SHELLMETAS just before the recipe or assignment with the
awk call, so that the left bracket won't trigger an unnecessary shell.  Then
restore the value of $SHELLMETAS from the other variable.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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