my ($type,@tokens)=split(/\~/,$line); if ($type eq "SendFiltered") { my ($tstamp,$cmnd_id,$alert_id,$send_id,$state,$svr_host) = @tokens[0-5]; my $sql = "INSERT ... } elsif ($type eq "AlertError") { ... } #### # %statements is an array of prepared SQL statement objects ready to have values plugged in %statements=( "AlertError"=>$dbh->prepare("INSERT INTO ERRORS (TSTAMP,CMND_ID,ALERT_ID,SEND_ID,DESTINATION,MESSAGE,STATE,SVR_HOST) VALUES (?,?,?,?,?,?,?,?)"), "SendCleared"=>$dbh->prepare("UPDATE SENDS..."), "... ); # %columns is an array of column position indicators corresponding to the %statements above %columns=( "AlertError"=>[0,1,2,3,4,5], "SendCleared"=>[... ); #### while ($line=...) { my ($type,@tokens)=split(/\~/,$line); $statements{$type}->execute(@tokens[@{$columns{$type}}]); }