Re: [exim] Need a script to separate headers

Top Page
Delete this message
Reply to this message
Author: Edgar Lovecraft
Date:  
To: Marc Perkel, exim
CC: 
Subject: Re: [exim] Need a script to separate headers
Edgar Lovecraft wrote:
> 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]...
> >
>


if you want the http:// in front of the domains change this line
    from: print STDOUT "$1\n" if m{http://([A-Za-z0-9.-]+).*$};
      to:   print STDOUT "$1\n" if m{(http://[A-Za-z0-9.-]+).*$};
and for the one liner version
    from: print "$1\n" if m!http://([A-Za-z0-9.-]+).*$!;}'
    to:   print "$1\n" if m!(http://[A-Za-z0-9.-]+).*$!;}'


>
> 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--

--