I doubt you expected commentary on your code, but hopefully this will be helpful to both you and anyone else reading.
On Sat, Oct 19, 2002 at 12:54:18AM +0600, Rakhitha Malinda Karunarathne wrote: You forgot -w and use strict. > $|=1; #*********************** Set auto Flush This sets autoflush on STDOUT, which is never used. To set autoflush on each of the handles you would either have to select() each handle then set $| to 1, or use IO::Handle and the ->autoflush method. > #*********************** Operning and Locking files if u use in non > multiuser environment ignore flock commands > open(FIRSTIN,"<infile01.ext"); > open(SECIN,"<infile02.ext"); You should always check your opens. > flock(FIRSTIN,LOCK_SH); > flock(SECIN,LOCK_SH); You have to be careful about trying to lock multiple files; if you have two processes trying to lock the same files they could deadlock. You should either check the return values of your flock and handle any errors appropriately, pick one file to lock and use that as an ad-hoc lock file, or have a seperate file used only for locking. > open(FIRSTOUT,">out01.ext"); > open(SECOUT,">out02.ext"); Again, check your opens. You also just truncated the files prior to locking them, which makes the locks somewhat pointless. > flock(FIRSTOUT,LOCK_EX); > flock(SECOUT,LOCK_EX); > > > #***************************** Following loop will exit when all the lines > in boath files are read > > $read=1; > while ($read){ > $read=0; > > > if ($in = <FIRSTIN>){ If the last line of the file is "0", or any other false value, with no trailing newline, this test will fail. -w will warn about this. > print FIRSTOUT "$in"; > $read=1; > } > > if ($in = <SECTIN>){ > print SECOUT "$in"; > $read=1; > } > > > } > > #****************************** Closing and unlocking files files if u use > in non multiuser environment ignore flock commands > flock(FIRSTOUT,LOCK_UN); > close(FIRSTOUT); > > flock(SECOUT,LOCK_UN); > close(SECOUT); > > flock(FIRSTIN,LOCK_UN); > close(FIRSTIN); > > flock(SECIN,LOCK_UN); > close(SECIN); Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]