Hey guys, I was hoping this group could help me with a problem I'm having while reading and writing z/OS datasets in Perl. The basic issue is that I'm reading fixed length records that contain both EBCDIC fields and binary fields. Sometimes the binary fields happen to contain X'0D', the EBCDIC carriage return. This causes a record to be split in two while being read or written. So I would like to process the dataset "record by record" instead of "line by line". Here is what I am trying in the code:
Open the input and output datasets: -------------------------------------------- $infh = mvsopen("//'USERBTC.INFILE'","r,lrecl=105,recfm=FB,blksize=27930") or die $|; $outfh = mvsopen("//'USERBTC.OUTFILE'","w,lrecl=105,recfm=FB,blksize=27930") or die $|; Read the record into $record variable --------------------------------------------- $recordsize = 106 # lrecl + 1 to account for trailing CR read($infh, $record, $recordsize); # using read() instead of <$infh> to avoid stopping at incidental CR's in binary fields Write the record back to output file: ----------------------------------------------- mvswrite($outfh,$record,$recordsize); # write back including trailing CR I was able to get the records that contain x'0D' read in as a whole by using read() in order to read in 106 bytes at a time, regardless of what the bytes are. But I am still having the issue of splitting 1 record into 2 when writing out. And even worse, part of my data is missing in the output because it is being interpreted as a CR. Here is an example of an input and output dataset with this issue: Input: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+ AAAC.DB39.IT40H2.LOAD 1996156 2014100 2014100 0000000 00005 N 1 ...z .... MD010703 CCCC4CCFF4CEFFCF4DDCC444444444444444444444444FFFFFFF4FFFFFFF4FFFFFFF4FFFFFFF4FFFFF4D4F4000A400004DCFFFFFF 1113B4239B934082B361400000000000000000000000019961560201410002014100000000000000050501000090001D044010703 Output (split in two): ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+ AAAC.DB39.IT40H2.LOAD 1996156 2014100 2014100 0000000 00005 N 1 ...z ... CCCC4CCFF4CEFFCF4DDCC444444444444444444444444FFFFFFF4FFFFFFF4FFFFFFF4FFFFFFF4FFFFF4D4F4000A40004444444444 1113B4239B934082B3614000000000000000000000000199615602014100020141000000000000000505010000900010000000000 MD010703 4DCFFFFFF444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 044010703000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Does anyone know how process records 1 record at a time, even if they contain carriage returns? Thanks for any help anyone may be able to give, let me know if you need any more information. -Brandon T. Cooper