procmail
[Top] [All Lists]

padding a string

2008-08-25 05:20:59
Hi

I'm struggling with a procmail recipe - as a complete newbie to procmail I should add.

Basically the pseudo code for what I want is as follows:

extract string from header.

if length($string) < 6
 pad $string left spaces to 6;
if test -d $string
 file the email into the folder $string
else
 forward to bad_folders alias;

What I have so far is:

:0
* ^X-My-Header:[ \t]*\/$
{
 STRING=${MATCH}
 :0
 * ? test ! -d $MATCH
 {
    ! bad_folder
 }
 $MATCH
}

I've managed to fudge my way so far with lot's of help from the Search Engine Gods, but I'm stuck on the "pad" problem. I know I could write this as a shell script or a perl snippet and then pipe the value of the variable out to it but how do I get it back in again (or alternatively how do I do it within procmail?

P.S. I'll also happily accept any criticism, suggestions or advice.

TIA

Nigel

____________________________________________________________
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>