On Monday 08 September 2003 02:12, Doug Weimer wrote:
> On Sun, 2003-09-07 at 08:01, Jason Stubbs wrote:
> <snip>
>
> > # Can I combine the following two lines in any way?
> > # $mail_body = @$mail->body(); does not work.
> > $mail_body_ref = $mail->body();
> > @mail_body = @$mail_body_ref;
>
> @{$mail->body()} works here. If you want, you can also use
> foreach(@{$mail->body(}) below.

Okay, that worked great!

> > @body_text = split("\n", join(" ", @body_text));
> >
> > @ntfy_mail = ("Date:   $msg_date",
> >               "From:   $msg_from",
> >               "Subject:$msg_subj",
> >               "\n");
> >
> > # Can I combine this into one line? Can I combine it with the above?
> > for ($i = 0; $i < 20; $i++) {
> >     @ntfy_mail = (@ntfy_mail, "@body_text[$i]\n");
> > }
>
> Since you only want 20 lines you can use @body_text[0 .. 19] in the
> join. If you want to reduce everything to a few lines, you can use a
> second join to add the newlines:
>
> $text = join("\n", split("\n", join(" ", @body_text[0 .. 19])));

The problem with this is that the original @body_text sometimes has more than 
one newline per element. Thus, I was getting up to 40 lines output by doing 
something similar previously. However...

@body_text = split("\n", join("", @body_text));
@ntfy_mail = ("Date:   $msg_date",
              "From:   $msg_from",
              "Subject:$msg_subj",
              "\n", join("\n", @body_text[0..19]));

This does exactly what I want. And changing the " " to "" in the initial join 
fixed both bugs too! For the record, the bugs were:
1) A preceding the first body line.
2) Certain characters of Japanese text were being corrupted.

Thanks for everybody's help!

Best regards,
Jason

--
[EMAIL PROTECTED] mailing list

Reply via email to