blacksmith has asked for the wisdom of the Perl Monks concerning the following question:

I have just placed a node onto the Craft page. The different file and folder paths have been changed to violate the innocent. It is my first "real" Perl program. I am using it to access a folder every 180 seconds (give or take a few seconds for the program to complete). It makes a list of all the files in this folder with a .txt, .doc, .mta, .mpd extension. It waits (sleeps) 3 minutes then goes to the folder and copies these to two (or three depending on the report or file) other folders changing the extension of the .doc and .mta files. (These are ASCII files so there is not any data corruption.) It then deletes these files off of this location. The reason for the 3 minute delay is due to the fact that these files are being ftp'ed from a mainframe to here. My supervisor wanted the three minute delay to ensure that a file was not being copied or deleted before it was done being ftp'ed. A list is made of the files copied. This list is compared with another list made from a folder of batch files. When there is a match yet another list (or array) is made to run the batch file which process the data in the file. The purpose of my design was to make it easy for other programmers here in the office to write up batch file and just place them out on the specific drive and the only other updates that need to take place are upon the shoulders of the mainframe programmers to get the file out on the respected location. I would appreciate someon taking a look at the program and tell me if there are any ways that I can make this more efficient. And please keep in mind that this is from a someone who only just started learning perl. The name of the program is a program to go find documents in a file then copy them to seperate folders, delete them from the original folder, then run a batch to process the individual files with their respected batch files. I hope there is no problem ffinding it I did not want to take up that much extra room on this page. Thanks. And everyone have a good weekend. Blacksmith.
  • Comment on I need a critic (well actually just someone to give some constructive advice)

Replies are listed 'Best First'.
Re (tilly) 1: I need a critic (well actually just someone to give some constructive advice)
by tilly (Archbishop) on Jun 16, 2001 at 03:44 UTC
    Advice.

    Rather than assuming that 3 minutes is enough, make it the responsibility of the transfer script to take the name with an ending indicating it is ready to go, transfer it, and then rename it to the final name. That will be both faster and safer than waiting 3 minutes. Otherwise I can practically guarantee you that in a few years someone will ftp a large file across the country and your script will break.

      It might also be a good idea to calculate checksums for the file at each end (using Digest::MD5 for example). This is a good (if paranoid) way of making sure that the file made it through FTPing.

      Of course, if you're really paranoid you would do a character-by-character comparison, can't go trusting checksums... ;-)

      --
      Kevin O'Rourke