procmail
[Top] [All Lists]

Re: capturing the OR that succeeds ???

2004-05-14 06:16:59
Ruud H.G. van Tol wrote:

I was missing an incarnation. Because most mail won't match,
do the optimal test for that first.

  :0D
  * B ?? ()\/(aaa|bbb|ccc|ddd|eee)
  {
     :0 D fw h
     * B ?? 9876543210^0 ()\/aaa
     * B ?? 9876543210^0 ()\/bbb
     * B ?? 9876543210^0 ()\/ccc
     * B ?? 9876543210^0 ()\/ddd
     | formail -I "X-Procmail: alphabet soup: $MATCH"

     :0 A
     alphabet/soup
  }

There's no reason to need in the outer condition nor even to split the tests in two. It will be clearer if we put the weight at the start of each condition and the search-area restriction after it to emphasize the distinction between the absolute condition and the weighted ones:

   MATCH # don't load it with eee; there may be no alphabet soup at all

   :0 D fw h
   * B ?? aaa|bbb|ccc|ddd|eee
   * 9876543210^0 B ?? ()\/aaa
   * 9876543210^0 B ?? ()\/bbb
   * 9876543210^0 B ?? ()\/ccc
   * 9876543210^0 B ?? ()\/ddd
   * 1^0
   | formail -I "X-Procmail: alphabet soup: ${MATCH-eee}"

   :0 A
   alphabet/soup

For that matter, we could put the B flag on the colon line and drop the "B ??" modifiers:

   MATCH # don't load it with eee; there may be no alphabet soup at all

   :0 B D fw h
   * aaa|bbb|ccc|ddd|eee
   * 9876543210^0 ()\/aaa
   * 9876543210^0 ()\/bbb
   * 9876543210^0 ()\/ccc
   * 9876543210^0 ()\/ddd
   * 1^0
   | formail -I "X-Procmail: alphabet soup: ${MATCH-eee}"

   :0 A
   alphabet/soup


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