procmail
[Top] [All Lists]

how to strip down a subject line

2008-11-20 14:29:41
I've got a variable definition recipe in my /etc/procmailrc
which defines SUBJECT, as:

:0
* ^Subject:\/.*
{ SUBJECT = $MATCH }

Now, what I want to do is make a copy of this, but strip
out everything but letters and spaces.  So, I wrote a
simple perl script (since I have no clue if this can be
done in procmail):

#!/usr/bin/perl
#MAIN
{
  my($subject) = shift(@ARGV) || '';
  my($newsubj) = '';
  #  we want to keep only letters and spaces
  for(my $x = 0; $x < length($subject); $x++) {
    if(substr($subject, $x, 1) =~ /[A-Za-z ]/) {
      $newsubj .= substr($subject, $x, 1);
    }
  }
  print $newsubj;
  exit;
}
#

Then, I tried to assign the output of this script into SUBJECT2.
It doesn't want to work, the SUBJECT2 is always blank.  I think
maybe it's passing out a blank.  Here is what I put into my
/etc/procmailrc:

STRIPCMD="/usr/local/bin/subject.stripper.pl '${SUBJECT}'"
LOG="STRIPCMD(${STRIPCMD})"
SUBJECT2=`$STRIPCMD`
LOG="SUBJECT2(${SUBJECT2})"

Now, STRIPCMD looks great and the log file shows it correctly.
However, SUBJECT2 is always blank.

Is something obviously wrong?
Is there a better way to do this?
I'd sure appreciate the assistance!

--
$DEFAULT.sig

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