Re: removing subject header (+another question)

1998-06-15 13:18:51
On June 15, 1998 at 08:02, "Nevel, Simeon" wrote:

Here's the original code from (starting at line 832)

    ## Get Subject ##
    if ($fields{'subject'} !~ /^\s*$/) {
      ($sub = $fields{'subject'}) =~ s/\s*$//;
    } else {
      $sub = 'No Subject';

You could add a couple of lines after the 
   ($sub = $fields{'subject'}) =~ s/\s*$//;

as follows:

    ## Get Subject ##
    if ($fields{'subject'} !~ /^\s*$/) {
      ($sub = $fields{'subject'}) =~ s/\s*$//;
      $tag = 'string to be removed';
      $pat = quotemeta $tag;
      $sub =~ s/$pat//;

        $sub =~ s/\Q$tag//;

Note, you may want to think about your regex.  For example, you may
want to anchor it (to the beginning of the string) to avoid
unwanted text deletion.  Also, what you have does not allow $tag
to contain meta stuff (eg: \s).

There is also a performance penalty since the regex will be recompiled
during each call.  You can use the /o modifier to avoid this.  However,
/o has its drawbacks when trying to use mhonarc to do multiple, serial
archive processing in a single process (something I am trying to make
possible in v2.3 in supporting custom Perl front-ends).

Earl, I know you pointed me at this before, but I lost my notes
and I know you reorganized the code somewhat for 2.2.0.

While I want subject lines to display in mixed case in 
the archive (just like they appear in the mail), I like the
subject-based threading to be case insensitive...

Glad you brought this up.  Forgot about it.  The place to
goto is and the compute_threads function.  The

        $stripsub{$index} = $tmp;

can be changed to:

        $stripsub{$index} = lc $tmp;

I think this should fix the problem (have not tested).


             Earl Hood              | University of California: Irvine
      ehood(_at_)medusa(_dot_)acs(_dot_)uci(_dot_)edu      |      Electronic 
Loiterer | Dabbler of SGML/WWW/Perl/MIME