use Net::MySQL; my $dbh = Net::MySQL->new( hostname => $MySQLserver, # Default use UNIX socket database => 'nb_reports', user => $user, password => $password, debug => 1 ); foreach $f (<\"${tlogs}\"/daily_data_gather_*.dat>) { while(){ $Line = $_; chomp $Line; ($Client_Name, $NBU_Type, $IP_Addr, $Platform, $Policy_Name, $Media_Server, $Total_Incr_Files, $Total_Incr_Kbytes, $Total_Full_Files, $Total_Full_Kbytes, $Avg_Incr_Files, $Avg_Incr_Kbytes, $Avg_Full_Files, $Avg_Full_Kbytes, $Total_Incr_Time, $Avg_Incr_Time, $Total_Full_Time, $Avg_Full_Time, $Incr_Count, $Full_Count, $Incr_Thru, $Full_Thru) = split(/,/, $Line); next unless ($Client_Name !~ /Client_Name/i); print "About to Add to DB - $Client_Name, $NBU_Type, $IP_Addr, $Platform, $Policy_Name, $Media_Server, $Total_Incr_Files, $Total_Incr_Kbytes, $Total_Full_Files, $Total_Full_Kbytes, $Avg_Incr_Files, $Avg_Incr_Kbytes, $Avg_Full_Files, $Avg_Full_Kbytes, $Total_Incr_Time, $Avg_Incr_Time, $Total_Full_Time, $Avg_Full_Time, $Incr_Count, $Full_Count, $Incr_Thru, $Full_Thru, $f\n"; $dbh->query("INSERT INTO policybyclient VALUES \(\'$Client_Name\', \'$NBU_Type\', \'$IP_Addr\', \'$Platform\', \'$Policy_Name\', \'$Media_Server\', \'$Total_Incr_Files\', \'$Total_Incr_Kbytes\', \'$Total_Full_Files\', \'$Total_Full_Kbytes\', \'$Avg_Incr_Files\', \'$Avg_Incr_Kbytes\', \'$Avg_Full_Files\', \'$Avg_Full_Kbytes\', \'$Total_Incr_Time\', \'$Avg_Incr_Time\', \'$Total_Full_Time\', \'$Avg_Full_Time\', \'$Incr_Count\', \'$Full_Count\', \'$Incr_Thru\', \'$Full_Thru\', \'$f\'\)"); print "Query Result: " . $dbh->get_error_message . "\n"; } #unlink $filename; #} }