Greetings:
As part of a data warehouse project, I am having to use perl (so that
we dont have to write dozens of COBOL programs) to extract data from
existing RMS indexed files to create flat files for later export to the
data warehouse. Some of these records have binary data (actually packed
decimal) that seems to be interpreted as line feeds on output. I was
able to get around the problem of reading the files by installing
VMS::IndexedFile (a test script returned exactly the right number of
records, with no unexpected "splits"), but I am not able to write an
output file and have it interpreted properly. In this one instance, I
am reading a file that has 64 records, but when write the file out, it
has 84 records. I thought that maybe VMS::Stdio could help me around
this, and I have tried several combinations of options on the vmsopen
call (for the output file), but none will write the correct output.
When I run the script and then look at the file with eve, I get either
3, 20, or 84 (but never 64) records in the output file. If I run
SyncSort like this:
$ ssort
/infile ajfile.dat
/outfile ajfile-flat.dat sequential
/copy
/end
I get an output file that looks like this:
File organization: Sequential
Shelved state: Online
Caching attribute: Writethrough
File attributes: Allocation: 69, Extend: 0, Global buffer count: 0
No version limit, Contiguous best try
Record format: Variable length, maximum 0 bytes, longest 894 bytes
Record attributes: Carriage return carriage control
RMS attributes: None
and I can look at it with eve and see the correct number of records.
When I try basically the same thing with my perl script which looks like
this:
use VMS::IndexedFile;
use VMS::Stdio qw(&flush &sync &vmsopen);
tie(%h, VMS::IndexedFile, "ajfile.dat",0,O_RDONLY);
$fh = vmsopen(">ajfile-flat.dat") or die $!;
while ($_ = $h{''}) { # read from indexed file
print $fh "$_\n"; # write flat file
}
flush($fh);
sync($fh);
undef $fh;
I get the same description for the new file:
File organization: Sequential
Shelved state: Online
Caching attribute: Writethrough
File attributes: Allocation: 69, Extend: 0, Global buffer count: 0
No version limit
Record format: Variable length, maximum 0 bytes, longest 894 bytes
Record attributes: Carriage return carriage control
RMS attributes: None
but eve sees 84 records in the file, apparently because of binary data
causing some split lines. I have tried various option combinations on
the vmsopen command, but I haven't stumbled upon the correct one yet
(adding rfm=var causes 84 records to be written, rfm=fix causes perl to
die with a "maximum record size" error). Has anyone been down this road
before and can offer advice? Thanks...
Jim McCullars
University of Alabama in Huntsville