First try is the naive "print first n lines". That approach is quickly thrown out the window. Grumbling ensues about the evils of HTML email. Spam promptly materializes containing roughly fourteen long paragraphs about random body part enlargement, without a line break anywhere in sight.
I found a rather easy solution, after some thought - we run this on Linux, after all, so why not use the traditional Unix utilities:
$spam = grabmsg($mailnum);
open HEAD, "| fold | head -24";
print HEAD $spam;
No sense in reimplementing everything in Perl if you can think of something else that does the job already. There probably are twenty-five ways of doing this in pure Perl that would be more elegant, if you know of and remember them. I had two days to build this, so I grabbed the first approach I could think of that worked.
No comments:
Post a Comment