Re: [exim] Need a script to separate headers

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Edgar Lovecraft
Datum:  
To: Marc Perkel, exim
CC: 
Betreff: Re: [exim] Need a script to separate headers
Marc Perkel wrote:
>
> That's pretty good. Can you modify it to include all links within the
> body of the message? Doesn't have to be the full link - just up through
> the domain.
>

..[snip]...
>


This should do it

<get_headers_and_http.pl>
#!/usr/bin/perl
use strict;
my ($_firstHeader,$_lastHeader,$_message) = (0,0,0);
while (<STDIN>) {
    ($_firstHeader,$_lastHeader) = (1,0) and $_message++ if /^From /;
    ($_firstHeader,$_lastHeader) = (0,1) if /^$/;
    s/^From .*$/\nMESSAGE HEADERS FOR MESSAGE: $_message/;
    print STDOUT if $_firstHeader && !$_lastHeader && !/^\s*$/;
    print STDOUT "$1\n" if m{http://([A-Za-z0-9.-]+).*$};
}
</get_headers_and_http.pl>


the no message seperator version

<get_headers_and_http.pl>
#!/usr/bin/perl
use strict;
my ($_firstHeader,$_lastHeader) = (0,0);
while (<STDIN>) {
    ($_firstHeader,$_lastHeader) = (1,0) if /^From /;
    ($_firstHeader,$_lastHeader) = (0,1) if /^$/;
    s/^From .*$//;
    print STDOUT if $_firstHeader && !$_lastHeader && !/^\s*$/;
    print STDOUT "$1\n" if m{http://([A-Za-z0-9.-]+).*$};
}
</get_headers_and_http.pl>



For the one liner version

<perl_1line>
perl -e 'my($f,$l)=(0,0);while(<STDIN>){($f,$l)=(1,0)if/^From /;($f,$l)=
(0,1)if/^$/;s/^From .*$//;print if$f&&!$l&&!/^\s*$/;print "$1\n" if m!
http://([A-Za-z0-9.-]+).*$!;}'
</perl_1line>

--

--EAL--

--