I have written a short script that reads data from a file and attempts to separate the data into separate a file when it sees ####### and !!!!!!! as delimiters.&nbsp; The problem I am having is that the script opens writes and closes the first file with no problem but not additional new files for the rest of the occurrences of <br>####### and !!!!!!!<br><br>#!/usr/bin/perl -w<br># test_file_writer.pl<br><br>open(DEV, "&lt;test_FILEEEEEE");<br><br># get a nice date string for naming an email file<br>my ($yr, $mo, $day, $hr, $min, $sec) = (localtime)[5,4,3,2,1,0];<br>my $date = $sec . $min . $hr . $day . ($mo + 1) . ($yr + 1900);<br><br>while($_ = &lt;DEV&gt;) {<br><br>&nbsp; print $_;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # show the output)<br><br>if ($_ =~ /#######/) {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #this is the beginning of a new file<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "THIS IS THE BEGINNING OF A NEW FILE\n";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $write_file =
 "y";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open(NEW_FILE, "&gt;NEW_FILE" . $date) || die "CANT OPEN NEW_FILE: $!\n";<br><br>}<br><br>if ($write_file eq "y") {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print NEW_FILE $_;<br><br>} #end of if<br><br>if ($_ =~ /!!!!!!!/) {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Closing File\n";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close (NEW_FILE) || die "CAN'T CLOSE NEW_FILE: $!";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $write_file = "n";<br><br>} # end of if<br><br>} # end of while<br>## END<br><br>Additionally confusing is that it does not die on open or close like one would think if it were unable to open and close.<br><br>Here the input file (test_FILEEEEEE):<br><br>#######<br>richard@rushlogistics.com<br>this is the body of a file<br>!!!!!!!<br>#######<br>richard@rushlogistics.com<br>this should be seprate file<br>!!!!!!!<br>#######<br>richard@rushlogistics.com<br>this should be another serperate
 file<br>!!!!!!!<br>#######<br>richard@rushlogistics.com<br>this should be another file<br>!!!!!!!<br>#######<br>richard@rushlogistics.com<br>and this just another<br>!!!!!!!<br><br>After the program executes I end up with only 1 new file like NEW_FILE267523122007 when the script should create 5 of them. <br><br>Any ideas as to where I've gone wrong would be greatly appreciated.<br><br>Thanks,<br><br>Richard<br><BR><BR>Your beliefs become your thoughts.  Your thoughts become your words.  Your words become your actions.  Your actions become your habits.  Your habits become your values.  Your values become your destiny.  -- Mahatma Gandhi