procmail
[Top] [All Lists]

Re: padding a string

2008-08-25 18:22:31
On 25-Aug-2008, at 04:16, Nigel Allen wrote:
[ I'm not even going to try to look at your code ]

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?


Here's how I pad a '0' onto a single digit number:

0
1         PADD = "0"$MATCH
          :0
2         * PADD ?? ...
         {
            :0
3            * PADD ?? ^^.\/..
4            { PADD = $MATCH }
         }
5

0: Match contains either a ## or a # (trust me, it does)
1: we add a 0 to the left of $MATCH, regardless if it is 1 or two digits.
2: check to see if the value is now 3 characters long
3: if it is, match to the right most two characters
4: set PADD to the right most two characters
5: if the PADD is not three characters, it must be two (0#), so do nothing.

either way, PADD comes out at two digits.

--
Was it everything you wanted to find? and did you miss me while you
        were looking for yourself out there?

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