problems writing multiple files

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2006
Posts: 1
Reputation: vann is an unknown quantity at this point 
Solved Threads: 0
vann vann is offline Offline
Newbie Poster

problems writing multiple files

 
0
  #1
Oct 3rd, 2006
Hi

I have a problem at writing multiple files. I have this code where I write several XML files (the number of files it's dynamic). I use a loop and in Linux works fine but the problem is Windows.

For example let's say that I want to write a long essay into 1 file, Windows and Linux do it as it should be, the problem comes when I want to write that same essay (divided into 5 parts) in 5 files. Linux works fine but windows skips the first part (the first file is not written) and the remaining parts are written well.. if I want to write the essay into 10 files, the first three are not written and as the number of files grows so does the number of files not written.

Does anyone knows why could this be? Next is the part of the code where I write into the files.

  1. local *FILE_X;
  2. eval {
  3. if(substr($filename, length($filename) - 4) eq '.txt') {
  4. #this does nothing yet
  5. }
  6. else {
  7. my $success = open ::FILE, "> $filename";
  8. unless($success) {
  9. $output->Error("Can not open file: $filename");
  10. return $False;
  11. }
  12.  
  13. print ::SITEMAP $FILE_HEADER;
  14. foreach my $line (@{$self->{_set}}) {
  15. $line->WriteXML(*FILE_X{IO});
  16. }
  17. print ::FILE $FILE_FOOTER;
  18.  
  19. close ::FILE;
  20. }
  21. };
  22. if($@) {
  23. $output->Fatal("Couldn't write out to file: $filename");
  24. }
  25. chmod(0644, $filename);
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 4839 | Replies: 0
Thread Tools Search this Thread



Tag cloud for Perl
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC