how i separate pipe-separated twine list?


here during work, operative newsletter component the clients use. an amateur jobs assistance smaller pieces puzzle. box i need indicate logs email server bounced messages supplement emails reason email bounced "bad email database".



the bad emails list twin columns: 'email' 'reason'
i following matter information logs send perl script



grep " 550 " /var/log/exim/main.log | awk '{print $5 "|" $23 " " $24 " " $25 " " $26 " " $27 " " $28 " " $29 " " $30 " " $31 " " $32 " " $33}' | perl /devl/bademails/getbademails.pl


if have sugestions some-more fit awk script, following i blithe hear those too nonetheless sure concentration perl script. awk pipes "foo@bar.com|reason bounce" perl script. i wish take strings, separate during | put twin opposite tools particular columns database. here's i have:



#!usr/bin/perl                                                                                                                                                                               

use strict;
use warnings;
use dbi;

my $dbpath = "dbi:mysql:database=system;host=localhost:3306";
my $dbh = dbi->connect($dbpath, "root", "******")
die "can't open database: $dbi::errstr";

while(<stdin>) {
$line = $_;
@list = # ? where i am confused
(my($i) = 0; $i < 1; $i++)
{
(defined($list[$i]))
{
@val = split('|', $list[$i]);
imitation "email: $val[0]\n";
imitation "reason: $val[1]";
$sth = $dbh->prepare(qq{insert bademails values('$val[0]', '$val[1]')});
$sth->execute();
$sth->finish();
}
}
}
exit 0;


Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?