Re: [exim] redirecting email to perl script

Pàgina inicial
Delete this message
Reply to this message
Autor: Edgar Lovecraft
Data:  
A: Exim Users Mailing List
Assumpte: Re: [exim] redirecting email to perl script
Peter Bowyer wrote:
>
> On 22/04/05, Markus Hardiyanto <informatics2k1@???> wrote: > here
> is my script:
> > ---begin---
> > #!/usr/bin/perl
> >
> > $email = <STDIN>;
> >
> > open (LOGGING, ">>/var/log/dnsbl_log");
> > print LOGGING "$email\n";
> > close LOGGING;
> > ---end---
>

..[snip]...
>
> You need to brush up on your perl. The code you wrote grabs the first
> line from stdin - hence your results. You need a loop to process the
> whole stream.


My thoughts exactly.

> open (LOGGING, ">>/var/log/dnsbl_log");
> while (<STDIN>) {
> print LOGGING "$_\n";
> }
>
>
> Or something similar. Completely untested, may be dangerous for young
> children and the elderly.


or
@email = <STDIN>;
open (LOGGING, ">>/var/log/dnsbl_log");
print LOGGING "@email\n";
close LOGGING;

however, a while loop on <STDIN> is much easier on the memory overhead

so is a:

use IO::File;

$email = 'STDIN';

while ( defined($_ = $email->getline()) ) { print }

--

--EAL--

--