while(1) { #get line of code $new_line #get line's date stamp $line_time #if file doesnt exist create it if (! -e $DATA_DIRECTORY.$filename.".ascii") { if (tell(CURRENT_FILE) != -1) {$file = $fileholder[0]; close CURRENT_FILE; } else {print "File cant be closed bc hasnt been made yet\n";} #open this file open(CURRENT_FILE, ">>$DATA_DIRECTORY".$line_time.".ascii") || print "$line_time.ascii could not be created\n"; $fileholder[0] = *CURRENT_FILE; $file = $fileholder[0]; #add line to $NEW_FILE print $file $new_line."\n" || print "data COULDNT be printed to CURRENT_FILE\n"; } else { #write to file and send $file = $fileholder[0]; print $file $new_line; #need a typeglob or it wont print b/c CURRENT_FILE is local } } #end of while loop