Here is my new Perl module, MPE::File. It is version 0.01 as the
documentation is quite sparse and many of the functions have had only
minimal testing. Feedback is appreciated.
As always, you can download it from CPAN (www.cpan.org), or from
http://invent3k.external.hp.com/~KEN.HIRSCH/
Second, I have added a slight convenience to the MPE::CIvar module-- There
is now a 'hpcicmds' subroutine where you can give a whole list of commands.
The errors and other parameters are passed implicitly (more Perlish, ya
know).
Third, I have improved my mail program so that it can send encrypted mail
(using OpenSSL, which installs easily on MPE). If anybody's interested, I
can post it, too.
NAME
MPE::File - Perl extension for accessing MPE File intrinsics
SYNOPSIS
use MPE::File;
$file = MPE::File->new("FRED.PUB,old;acc=in")
or die "Cannot open FRED.PUB: $MPE_error\n";
OR
$file = MPE::File->hpfopen(2, "FRED.PUB", 3, 1, 11, 0)
or die "Cannot open FRED.PUB: $MPE_error\n";
OR
$file = MPE::File->fopen("FRED.PUB", 1, 0)
or die "Cannot open FRED.PUB: $MPE_error\n";
$rec = $file->readrec(); # use this instead of fread
$rec = $file->freadbykey($key, $keyloc);
$rec = $file->freadlabel( [$labelid] );
$rec = $file->freaddir($lrecnum);
$rec = $file->freadc();
$file->fread($buffer, $bufsize);
$file->writerec($buffer, [$controlcode] )
# use this instead of fwrite
$file->fupdate($buffer);
$file->fwritedir($buffer, $lrecnum);
$file->fwritelabel ($buffer, [$labelid] )
$file->fwrite($buffer, $length, $controlcode)
$file->fpoint($lrecnum);
$file->fcontrol($itemnum, $item);
$file->fdelete( [$lrecnum] );
$file->fsetmode($modeflags);
$file->fremove();
$file->fgetkeyinfo($param, $control);
$file->ffindbykey($value, $location, $length, $relop);
$file->printfileinfo();
@info = $file->ffileinfo(1, 3, 7, 9);
@info = flabelinfo("FRED.PUB", $mode, 1, 3, 7, 9);
$errmsg = ferrmsg($fserrcode);
hperrmsg($displaycode,...)
DESCRIPTION
The primary reference should be the MPE/iX Intrinsic Reference
Manual (available at http://docs.hp.com/mpeix/all/index.html)
Notice that there are some difference in parameters. For
example, I take care of all the delimited strings in HPFOPEN
Subroutines return 0 or undef on failure; check $MPE_error for
the error number and/or string (both should be valid).
MPE::File->new($x) is the same as MPE::File->hpfopen(52, $x)
which, to quote the Intrinsic manual:
"Passes a character string that matches the file equation
specification syntax exactly."
You can pass other HPFOPEN parameter pairs after the first
one, although almost all can be specified in the file
equation.
One that can't be is to save a file right away, on HPFOPEN,
instead of waiting until FCLOSE. You can do that like this:
$file =
MPE::File->new("FRED,new;rec=-80,,f,ascii;msg;acc=in", 3, 4)
or die "Cannot open FRED: $MPE_error\n";
(Notice the 3, 4 pair at the end.)
If you use FFREADBYKEY, remember to pad out your keys to the
full length. Also, if they are binary keys, you'll need to
use pack, otherwise a number will be converted to its string
equivalent.
This documentation will be expanded at some point; feel free
to send me suggestions (or completed paragraphs).
EXPORT
flabelinfo $MPE_error
AUTHOR
Ken Hirsch <[log in to unmask]>
This module may be used and distributed on the same terms as Perl.
SEE ALSO
perl(1).
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|