D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Perl quickie



On Thu, Sep 05, 2002 at 12:17:52PM +0100, Simon Waters wrote:

sed -e "s/X-Trace:/X-X-Trace:/ ;
s/X-Complaints:/X-X-Complaints:/ ; 
s/NNTP-Posting-Date:/X-NNTP-Posting-Date:/"     

Don't forget that will affect the body. Try this:

#!/usr/bin/perl

use News::Article;

@rename = qw(X-Trace X-Complaints NNTP-Posting-Date);

my $art = News::Article->new(\*DATA) || die "in pain: $!";;

$art->rename_header($_,"X-$_",'add') for @rename;

$art->write(STDOUT);

__DATA__
OKheader: stuff
OKheader2: other stuff
Trace: not X-trace
X-Complaints: thang
X-X-Complaints: existing
NNTP-Posting-Date: wibble

details of pleasure

these are not headers.

X-Complaints: thang
OKheaders2: other stuff


#################

Change the action of the rename, to clobber or something, if you like.

HTH

Steve

PS You do know there is a perl group, don't you!

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly