humbling! Can't believe I missed that.&nbsp; Thank you very very much Don.<br><br><b><i>Don Drake &lt;don@drakeconsult.com&gt;</i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> The date is setup only once at the beginning of the script, so you  <br>only get one file.<br><br>Put this in the while loop:<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>-Don<br><br>On Dec 23, 2007, at 10:31 AM, Richard Reina wrote:<br><br>&gt; I have written a short script that reads data from a file and  <br>&gt; attempts to separate the data into separate a file when it sees  <br>&gt; ####### and !!!!!!! as delimiters.  The problem I am having is that  <br>&gt; the script opens writes and closes the first file with no problem  <br>&gt; but not additional new files for the rest of the occurrences of<br>&gt; ####### and
 !!!!!!!<br>&gt;<br>&gt; #!/usr/bin/perl -w<br>&gt; # test_file_writer.pl<br>&gt;<br>&gt; open(DEV, "<test_FILEEEEEE");><br>&gt;<br>&gt; # get a nice date string for naming an email file<br>&gt; my ($yr, $mo, $day, $hr, $min, $sec) = (localtime)[5,4,3,2,1,0];<br>&gt; my $date = $sec . $min . $hr . $day . ($mo + 1) . ($yr + 1900);<br>&gt;<br>&gt; while($_ = <DEV>) {<br>&gt;<br>&gt;   print $_;        # show the output)<br>&gt;<br>&gt; if ($_ =~ /#######/) {<br>&gt;<br>&gt;       #this is the beginning of a new file<br>&gt;       print "THIS IS THE BEGINNING OF A NEW FILE\n";<br>&gt;       $write_file = "y";<br>&gt;       open(NEW_FILE, "&gt;NEW_FILE" . $date) || die "CANT OPEN  <br>&gt; NEW_FILE: $!\n";<br>&gt;<br>&gt; }<br>&gt;<br>&gt; if ($write_file eq "y") {<br>&gt;<br>&gt;       print NEW_FILE $_;<br>&gt;<br>&gt; } #end of if<br>&gt;<br>&gt; if ($_ =~ /!!!!!!!/) {<br>&gt;<br>&gt;       print "Closing File\n";<br>&gt;       close (NEW_FILE) || die "CAN'T CLOSE NEW_FILE:
 $!";<br>&gt;       $write_file = "n";<br>&gt;<br>&gt; } # end of if<br>&gt;<br>&gt; } # end of while<br>&gt; ## END<br>&gt;<br>&gt; Additionally confusing is that it does not die on open or close like  <br>&gt; one would think if it were unable to open and close.<br>&gt;<br>&gt; Here the input file (test_FILEEEEEE):<br>&gt;<br>&gt; #######<br>&gt; richard@rushlogistics.com<br>&gt; this is the body of a file<br>&gt; !!!!!!!<br>&gt; #######<br>&gt; richard@rushlogistics.com<br>&gt; this should be seprate file<br>&gt; !!!!!!!<br>&gt; #######<br>&gt; richard@rushlogistics.com<br>&gt; this should be another serperate file<br>&gt; !!!!!!!<br>&gt; #######<br>&gt; richard@rushlogistics.com<br>&gt; this should be another file<br>&gt; !!!!!!!<br>&gt; #######<br>&gt; richard@rushlogistics.com<br>&gt; and this just another<br>&gt; !!!!!!!<br>&gt;<br>&gt; After the program executes I end up with only 1 new file like  <br>&gt; NEW_FILE267523122007 when the script should create 5 of
 them.<br>&gt;<br>&gt; Any ideas as to where I've gone wrong would be greatly appreciated.<br>&gt;<br>&gt; Thanks,<br>&gt;<br>&gt; Richard<br>&gt;<br>&gt;<br>&gt; Your beliefs become your thoughts. Your thoughts become your words.  <br>&gt; Your words become your actions. Your actions become your habits.  <br>&gt; Your habits become your values. Your values become your destiny. --  <br>&gt; Mahatma Gandhi_______________________________________________<br>&gt; Chicago-talk mailing list<br>&gt; Chicago-talk@pm.org<br>&gt; http://mail.pm.org/mailman/listinfo/chicago-talk<br><br>_______________________________________________<br>Chicago-talk mailing list<br>Chicago-talk@pm.org<br>http://mail.pm.org/mailman/listinfo/chicago-talk<br></DEV></test_FILEEEEEE");></blockquote><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