#!/usr/bin/perl if( @ARGV ){ $group = $ARGV[ 0 ]; shift; } if( @ARGV ){ $moderator = $ARGV[ 0 ]; shift; } @drop=("From\$", "Return-Path:", "Received:", "X-ML", "Error-To:", "X-UIDL:", "Precedence:", "Status:", "X-Distribute:", "To:", "Path:", "Newsgroups:"); open( BATCH, ">batch") || die "cannot open batch"; while( @ARGV ){ &mail2news( $ARGV[0] ); shift; } close( BATCH ); exit 0; sub mail2news() { local( $filename ) = @_; if( !open( IN, "<$filename" )){ print STDERR "$filename?\n"; return; } $base = $filename; $base =~ s@.*/([^/]+)$@\1@; $work = sprintf( "%s/tmp/m2n$$.%s", $ENV{"HOME"}, $base); open( OUT, ">$work") || die "cannot open $work.\n"; print OUT "Path: mailinglist\n"; print OUT "Newsgroups: $group\n"; print OUT "Approved: $moderator\n"; $last_dropped=0; while( ){ chop; last if( $_ eq "" ); if( /^[ \t]/){ print OUT "$_\n" unless $last_dropped; next; } ( $fieldname, $description )= /^([^ ]+) (.*)/; if( grep( $fieldname =~ /$_/i, @drop)){ $last_dropped = 1; next; } $last_dropped = 0; print OUT "$fieldname $description\n"; } print OUT "\n"; print OUT while( ); close( OUT ); close( IN ); print BATCH "$work\n"; }