#Open the results file open(OUTPUT,">Q:\\Results\\".$date_time."\\".$1."_results.txt") || do{warn "Could not open ".$item."::".$!; writeLogEntry($item." failed to open!");}; $rows = 0; #Write the results while(my @row = $sth->fetchrow_array) { $rows++; #Set output delimiter to the | $,="|"; #Remove trailing spaces map{s/\s*$//g} @row; print OUTPUT @row ."\n"; } #Output the number of rows affected writeLogEntry("Wrote ".$rows." results to ".$1."_results.txt."); #close the file close OUTPUT;