Heikki Hannikainen wrote:
> 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;
>
Yea that looks like a better way. I only wanted to remove the the part of
the line put there by sendmail, but removing any white space might be a good
idea for the BBS system. My big mistake the first time around was not to
limit the number of times it split. I should have done something like
this...
($junk,$subject) = split(/: /,$subject,2);
But then this appears to works too..
$subject = substr($subject,9,-1);
So I guess the big question is... Should I mess with the senders subject
line?
Maybe they want it to look like this:
Subject: HEY! WAKEUP! ;-)
>
> (^ is beginning of line, \s+ is one or more whitespaces, search &
> replace for a zero-length string, i is for case insensitivity)
>
Thanks... I didn't know anything about the \s+
>
> Also, you still might fail on a multi-line subject entry if your parser
> does not handle them earlier.
>
Yup it'll ignore anything past the first newline. A subject is only suppose
to be one line isn't it?
Bob