Thu 97-12-04 "David W. Tamkin" <dattier(_at_)miso(_dot_)wwa(_dot_)com>
list.procmail
| Jari Aalto explained,
| | I worded my question badly, I wantod to "chop off", ie delete 2 last
|
| Oh ... that is nearly impossible without forking an outside process. The
| cheapest might be expr because it doesn't need a shell to pipe echo to it
| (as sed would and I believe perl would):
|
| savemetas=$SHELLMETAS
| SHELLMETAS # Get your asterisk out of there!
| VAR=`expr "$VAR" : '\(.*\)..'`
| SHELLMETAS=$savemetas
Okay. Then I think the best, cheapest and most powerfull (overall) tool for
*simple* string manipulations would be awk. Perl takes too much overhead at
startup. Is there any way to measure to way or the other as procmail sees it?
I mean If I use some way
pipe | pipe | pipe
pipe| awk
pipe | perl o
or some other call
in awk there are two choices, if VAR is continuous block of characters,
notice this doesn't _need_ a file
VAR = ` awk 'BEGIN{ v = ARGV[1]; \
print substr(v,1,length(v)-2); exit }' \
"$VAR" `
|
must be continuous block, otw ARGV[1] cannot be used.
If not, then we must give _some_ file to get awk started:
VAR = ` awk '{print substr(v,1,length(v)-2); exit }' v="$VAR" /etc/passwd`
[score]
| No, it tests whether the head contains a null string (which it always does,
| so that condition is always true) and scores $VAR for its truth. If $VAR
| is not a number, we get an error, but if VAR was set as the score of an
| earlier recipe or as the result of an arithmetic calculation, that won't be
| a problem.
Thank you!
jari