in reply to Re^2: Mail:Audit Resend Problem
in thread Mail:Audit Resend Problem
2) This (look at perldoc -f exists):my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(t +ime); $date = "$mday/$mon/$year $hour:$min:$sec"; # THIS IS WRONG!!!! # do something like this instead: my @time = localtime; my $date = sprintf("%2d/%2d/%4d %02d:%02d:%02d", $time[4] + 1, $time[3 +], $time[5] + 1900, @time[2,1,0]);
should be replaced with:while(my ($key, $value) = each(%forward)) { if ($to =~ $key) { $local_address = $key; $forward_address = $value; } }
3) Use (see DBI docs) heredocs and placeholders. (Also, i believe this 'LEFT JOIN' should be just 'JOIN')if( exists $forward{$to} ){ $local_address = $key; $forward_address = $value; }
4) This:$sql = <<EOF; SELECT "tblForwardMail"."ForwardMailID", "tblFilterMail"."FilterMailEm +ail" FROM "tblForwardMail" LEFT JOIN "tblFilterMail" ON "tblForwardMail"."ForwardMail +ID"="tblFilterMail"."ForwardMailID" WHERE "tblForwardMail"."ForwardMailTo"=? EOF # $sth = $dbh->prepare($sql); # $sth->execute( $local_address ); # while (@row = $sth->fetchrow) { # push(@filter, $row[1]); # } # # But it seems like what you want next is just: (undef,$filter_address) = $dbh->selectrow_array($dbh,{},$local_address +); # make sure to pre-declare $filter_address
could be:foreach my $email_address(@filter) { if (($from =~ $email_address)){ $store = "YES"; } }
but if you use my comment #3, then it's just:$store = "YES" if grep( $_ eq $from, @filter );
BUT, you should treat $store as a boolean and give it true (1) and false (0, undef) values, so you don't have to string match 'YES' later..$store = "YES" if $from eq $filter_address;
5) This:$store = 1; # true $store = 0; # false if( $store ){ ... } if( ! $store ){ ... }
is "c-ish" .. here it's usally better to declare stuff just when it's being used (especially if it only exists in a limited block/scope)#Declare variables to be used including command line variables if need +ed my ($stored_email, $log, $to, $from, $forward_address, $store, $body, +$sql, $sth, $date, $local_address);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Mail:Audit Resend Problem
by tertullian01 (Acolyte) on Jun 21, 2005 at 17:23 UTC |