P
Paul Jones
Perhaps someone can help me with a little perl problem.
I want to take an message and write it out to a file, but I only
want specific header information. I have included what I have
got below (ripped from a mail2news script on the web), however
the comments header is often split over multiple lines (usually
4) and I want to include them all. The 2-4th lines of the header
all begin with spaces (usually 6 - perhaps its a tab).
The program does exactly what I want of it, except for missing
the lines beginning with a space.
open (INEWS, "| $program $options") ||
die "$program: can't run $news_poster_program\n";
# header loop
while (<STDIN>) {
last if /^$/;
s/(?i)^Date/Date/;
s/(?i)^From/From/;
s/(?i)^Subject/Subject/;
s/(?i)^Newsgroups/Newsgroups/;
s/(?i)^Comments/Comments/;
print INEWS
if /^(Date|From|Subject|Newsgroups|Comments):/i;
$saw_newsgroup |= ( $+ eq 'Newsgroups' );
}
die "$program: didn't get newsgroup from headers\n"
unless $saw_newsgroup;
print INEWS "\n";
print INEWS while <STDIN>; # gobble rest of message
I want to take an message and write it out to a file, but I only
want specific header information. I have included what I have
got below (ripped from a mail2news script on the web), however
the comments header is often split over multiple lines (usually
4) and I want to include them all. The 2-4th lines of the header
all begin with spaces (usually 6 - perhaps its a tab).
The program does exactly what I want of it, except for missing
the lines beginning with a space.
open (INEWS, "| $program $options") ||
die "$program: can't run $news_poster_program\n";
# header loop
while (<STDIN>) {
last if /^$/;
s/(?i)^Date/Date/;
s/(?i)^From/From/;
s/(?i)^Subject/Subject/;
s/(?i)^Newsgroups/Newsgroups/;
s/(?i)^Comments/Comments/;
print INEWS
if /^(Date|From|Subject|Newsgroups|Comments):/i;
$saw_newsgroup |= ( $+ eq 'Newsgroups' );
}
die "$program: didn't get newsgroup from headers\n"
unless $saw_newsgroup;
print INEWS "\n";
print INEWS while <STDIN>; # gobble rest of message