On Tue, 2002-04-23 at 17:00, Ron Powell wrote: > Basically, I have 30 records in one file and another file with 25 records... > these files are opened for reading, a record from the first file is paired > with a record from the second file and output a 3rd file. Obviously, the > first 25 records are fine, but the last five records are being paired with a > null value. The block of code below is my feeble attempt at detecting the > null value when the record is read and returning a dummy value so that there > are no nulls in the output file. > > I'm quite sure there is a more elegant way to do this. Suggestions, please? > > > sub getdept { > $getdept=<INFILE3>; > chop($getdept); > if (!($getdept)) { > $getdept="UNSPECIFIED"; > } > return $getdept > } > > > > > > ---------- > Ron Powell > Senior IT Analyst & > Network Administrator > gomembers, Inc. (Baltimore Office) > [EMAIL PROTECTED] > 410-494-1600 x4058 > <<...OLE_Obj...>>
I am not sure I understand your question correctly, but I think you want to merge two files and one file is larger than the other. For all lines in the first file that cannot be paired with lines in the second file you want to use the value UNSPECIFIED instead. Assuming that the data will always be strings and never be a string that evaluates to 0 (0, 00, 0e0, etc.) I would do that like this: do { $one = <INPUT_FILE_1> || "UNSPECIFIED"; $two = <INPUT_FILE_2> || "UNSPECIFIED"; print OUTPUT_FILE "$one $two"; } while ($one or $two); If I could not be sure that the data would never evaluate to 0, I would write it like this: do { $one = <INPUT_FILE_1>; $one = "UNSPECIFIED" unless defined $one; $two = <INPUT_FILE_2>; $one = "UNSPECIFIED" unless defined $one; print OUTPUT_FILE "$one $two"; } while ($one ne 'UNSPECIFIED' or $two ne 'UNSPECIFIED'); -- Today is Pungenday the 40th day of Discord in the YOLD 3168 Kallisti! Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]