I am writing a parser to read in ftp log files and insert into a databse. I have everything working fine, except the legacy billing system being used generates bills for each user instead of the master account. Therefore, as a bandaid, I need to attach an account field to each uid for each insert. I figured I could do this using more if statements within my loop, which seemed to work for one, but as I added an additional it stopped working properly. Any help would be appreciated. Here is the code that I am having trouble with.
Code:
while (<FILE>) { ($dow, $month, $day, $time, $year, $duration, $clientip, $size, $path, $type, $uid) = split(/\s+/); $date = "$dow,$month,$day,$time,$year"; # ATTACH USERS TO MASTER ACCOUNTS # ------------------------------- if ($uid eq "jdoe","bfoo","jjones") { $account = "abc"; } elsif ($uid eq "msmith") { $account = "xyz"; } elsif ($uid eq "zbills","vgoo") { $account = "asdf"; } # MAY NEED TO ADD MANY MORE elsif's OR COULD THESE BE ALL if's?; OR HOW COULD I REFERENCE A TEXT FILE OR DATABASE TABLE TO MATCH UID'S AND RETURN THE ACCOUNT TO BE ATTACHED TO EACH LINE OF LOG FILE BEING PARSED AND INPUT INTO DATABASE? # # CONVERT TYPE TO LEGACY DB METHOD # -------------------------------- if ($type eq "o") { $method = RETR; } elsif ($type eq "i") { $method = STOR; } unless ($size eq "-" || $duration eq "-") { $sth->execute($date,$clientip,$duration,$size,$method,$uid,$path,$account) or die "Couldn't execute statement: " . $sth->errstr; } }
Comment