humbling! Can't believe I missed that. Thank you very very much Don.<br><br><b><i>Don Drake <don@drakeconsult.com></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>> I have written a short script that reads data from a file and <br>> attempts to separate the data into separate a file when it sees <br>> ####### and !!!!!!! as delimiters. The problem I am having is that <br>> the script opens writes and closes the first file with no problem <br>> 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, "<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($_ = <DEV>) {<br>><br>> print $_; # show the output)<br>><br>> if ($_ =~ /#######/) {<br>><br>> #this is the beginning of a new file<br>> print "THIS IS THE BEGINNING OF A NEW FILE\n";<br>> $write_file = "y";<br>> open(NEW_FILE, ">NEW_FILE" . $date) || die "CANT OPEN <br>> NEW_FILE: $!\n";<br>><br>> }<br>><br>> if ($write_file eq "y") {<br>><br>> print NEW_FILE $_;<br>><br>> } #end of if<br>><br>> if ($_ =~ /!!!!!!!/) {<br>><br>> print "Closing File\n";<br>> close (NEW_FILE) || die "CAN'T CLOSE NEW_FILE:
$!";<br>> $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 <br>> 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 <br>> 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. <br>> Your words become your actions. Your actions become your habits. <br>> Your habits become your values. Your values become your destiny. -- <br>> Mahatma Gandhi_______________________________________________<br>> Chicago-talk mailing list<br>> Chicago-talk@pm.org<br>> 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