procmail
[Top] [All Lists]

Re: How I solved the mmm to mm

2004-02-10 16:01:27
LuKreme wrote:

      TEMPMON = $MATCH
      :0
      * 1^0 $TEMPMON ?? JAN
      * 2^0 $TEMPMON ?? FEB
      * 3^0 $TEMPMON ?? MAR
      * 4^0 $TEMPMON ?? APR
      * 5^0 $TEMPMON ?? MAY
      * 6^0 $TEMPMON ?? JUN
      * 7^0 $TEMPMON ?? JUL
      * 8^0 $TEMPMON ?? AUG
      * 9^0 $TEMPMON ?? SEP
      * 10^0 $TEMPMON ?? OCT
      * 11^0 $TEMPMON ?? NOV
      * 12^0 $TEMPMON ?? DEC
      {
         MYMONTH = $=
      }

Good grief. In what way is this better than, or even as good as, the suggestion I posted? And it tries all twelve comparisons even after already finding a match. [Also, those dollar signs are just waste.]

next step is to get MYMONTH to "05" from "5" but I think that's pretty
trivial

TMONTH = "0"$MYMONTH
TMONTH ?? ().*\/..
MYMONTH=$MATCH

or something.

Oy. For one thing, that won't work for the last three months of the year unless you right-anchor the extraction test. Even so ...

 :0
 * MYMONTH ?? ^^.^^
 { MYMONTH=0$MYMONTH }

Or you could combine it with your lovely list up there:

       TEMPMON = $MATCH
       :0
       * 100^0
       * 1^0 TEMPMON ?? JAN
       * 2^0 TEMPMON ?? FEB
       * 3^0 TEMPMON ?? MAR
       * 4^0 TEMPMON ?? APR
       * 5^0 TEMPMON ?? MAY
       * 6^0 TEMPMON ?? JUN
       * 7^0 TEMPMON ?? JUL
       * 8^0 TEMPMON ?? AUG
       * 9^0 TEMPMON ?? SEP
       * 10^0 TEMPMON ?? OCT
       * 11^0 TEMPMON ?? NOV
       * 12^0 TEMPMON ?? DEC
       {
          MYMONTH = $=

          :0
          * MYMONTH ?? 1\/..
          { MYMONTH = $MATCH }
       }

But my earlier post's code was much better all around.  Again,

MONTHSTRING=Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12

:0
* $ MONTHSTRING ?? $TEMPMON\/..
{ MYMONTH=$MATCH }

Personally, I have a fondness for the two-letter month abbreviations, but they don't sort properly and they don't translate well into other languages.


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