Am Montag, 17. Februar 2014, 19:04:48 schrieb Sam Varshavchik:
> Florian Lindner writes:
> 
> > Hello,
> >
> > I have this piece of code in my .mailfilter:
> >
> > MATCH1 = "None"
> > /^X-Flofify-Class: (.*)$/
> > class = $MATCH1
> > log "Class: $class"
> >
> > if ($class eq "None")
> >    to "$MDIR/florian.lind...@xgm.de"
> > else
> >    to "$MDIR/florian.lind...@xgm.de/.$class"
> >
> > But when there is no match at all (e.g. no X-Flofify-Class header existing) 
> >  
> > the value of MATCH1 is not None but still the one from the previous regexp  
> > operation (somewhere else in my code).
> >
> > How can I set a default value if not match is found?
> 
> This seems to work as expected for me:
> 
> logfile "maildrop.log"
> 
> /Subject: (.*)/
> 
> log "Subject match: $MATCH1"
> MATCH1="None"
> log "Match reset: $MATCH1"
> 
> /Snorkle: (.*)/
> 
> log "Match fail: $MATCH1"
> 
> Results in:
[correctness]

I've identified my problem, I used $VAR syntax for an assignement: $MATCH1 = 
"None", ironically, when I copy-pasted that piece of code I didn't grab the $ 
at the beginning... omg, sorry!

> But having said that, this is a bit awkward way to do this. You should use  
> an if statement:
> 
> if (/^X-Flofify-Class: (.*)$/)
> {
>    whatever=$MATCH1

Yeah, that looks better.

if (/^X-Flofify-Class: (.*)$/)
   to "$MDIR/florian.lind...@xgm.de/.MATCH1"
else
   to "$MDIR/florian.lind...@xgm.de"

Regards & thanks,
Florian

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
courier-users mailing list
courier-users@lists.sourceforge.net
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to