On Sat, 25 Sep 1999, Bob Meyer wrote:
> I found a problem with the way I was handling the subject line in
> mail2bbs.
> It's easy to fix... just change line 37 from this...
> ($junk,$subject) = split(/: /,$subject);
> to this...
> $subject = substr($subject,9);
> -($junk,$subject) = split(/: /,$subject);
> +$subject = substr($subject,9);
> chomp $subject;
This is incorrect, since there might be an arbitrary amount of
whitespace between the : and the subject field itself. That's probably why
your split failed - firstable there might be either ' ' or '\t' (or
any number of them) between the Subject: and the data, and it also broke
if a ": " appeared in the subject's text. And this substr does not remove
the whitespace in the beginning.
I'd probably go for a regexp:
$subject =~ s/^subject:\s+//i;
(^ is beginning of line, \s+ is one or more whitespaces, search &
replace for a zero-length string, i is for case insensitivity)
Also, you still might fail on a multi-line subject entry if your parser
does not handle them earlier.
- Hessu