Front page | perl.vmsperl |
Postings from January 2002
Re: PERL and RMS interface
Thread Previous
|
Thread Next
From:
Ruslan R. Laishev
Date:
January 20, 2002 00:48
Subject:
Re: PERL and RMS interface
Message ID:
3C4A85AC.516EDF6E@smtp.deltatel.ru
Thanks!
d.webb@mdx.ac.uk wrote:
>
> > Hello All!
> > Is there a .PM to get interface with RMS ?
>
> Well there is VMS-INDEXEDFILE-0_02
>
> >From the readme :-
>
> This used to be called VMDBM, and was repackaged in the VMS::
> namespace in April 1999.
>
> DESCRIPTION
> -----------
> This is a module for VMS Perl which implements DBM-like functionality
> using OpenVMS RMS Indexed files.
>
> This seems to work very well.
>
> The following is an example perl cgi script which creates an indexed file,
> writes and reads records from it :-
>
> #! perl
>
> use VMS::IndexedFile;
>
> print "Content-type: text/plain\n\n";
>
> # Create a file test.dat
> # Variable record format - maximum record size 10 characters
> # Primary key (Key 0) - starting position 0 , length 3 - character string
> # Second Index (Key 1) - consists of two key segments :
> # segment 0 : starting position 3 , length 2 - character string
> # segment 1 : starting position 0 , length 3 - character string
>
> $hobj = tie(%h,VMS::IndexedFile,"test.dat",0,O_RDWR|O_CREAT,
> "FILE; ORGANIZATION indexed; RECORD; CARRIAGE_CONTROL carriage_return;" .
> "FORMAT variable; SIZE 10;" .
> "KEY 0; CHANGES no; DUPLICATES no; SEG0_POSITION 0; SEG0_LENGTH 3;" .
> "TYPE string;" .
> "KEY 1; CHANGES no; DUPLICATES yes; SEG0_POSITION 3; SEG0_LENGTH 2;" .
> "SEG1_POSITION 0; SEG1_LENGTH 3; TYPE string;");
>
> # open second connection to file using secondary key
>
> tie(%h2,VMS::IndexedFile,"test.dat",1)
> or die "Can't open test.dat file: $!\n";
>
> # store a record with primary key 'ABC' + some other data
>
> $h{'ABC'} = 'ABC12345';
>
> # Primary key for record is "ABC"
> # Secondary key for record is "12ABC"
>
> # store another record with primary key 'DLW' + some other data
>
> $h{'DLW'} = 'DLWMDX';
>
> # Primary key for record is "DLW"
> # Secondary key for record is "MDDLW"
>
> $h{'DLX'} = 'DLX012345';
>
> # Primary key for record is "DLX"
> # Secondary key for record is "01DLX"
>
> # Print record with secondary key MDDLW
>
> print "\n\n The record with secondary key MDDLW is :- \n\n";
>
> print $h2{'MDDLW'};
>
> # Print record with primary key ABC
>
> print "\n\n The record with primary key ABC is :- \n\n";
>
> print $h{'ABC'};
>
> # close the connections
>
> untie(%h);
> untie(%h2);
>
> # reopen connections again so as to reposition at start of each index
>
> tie(%h,VMS::IndexedFile,"test.dat",0)
> or die "Can't open test.dat file: $!\n";
>
> tie(%h2,VMS::IndexedFile,"test.dat",1)
> or die "Can't open test.dat file: $!\n";
>
> # Print all records by primary key
>
> print "\n\n The records in primary key order are :- \n\n";
>
> while($recval = $h{''}) {print "$recval\n";}
>
> # Print all records by secondary key
> print "\n\n The records in secondary key order are :- \n\n";
>
> while($recval = $h2{''}) {print "$recval\n";}
>
> # close the connections
>
> untie(%h);
> untie(%h2);
>
> This works fine using perl v5.6.0 with the crinoid perl server addon to the
> OSU webserver under Alpha VMS 7.3.
>
> There is one problem you can't delete the file you create from within the
> script after you have finished.
>
> Also although the readme provides instructions on how to use the module there
> is no documentation setup for perldoc to read.
>
> (I would quite like to convert the readme into a perldoc documentation file and
> setup such documentation on my system but have no idea how to go about it).
>
> David Webb
> VMS and Unix team leader
> CCSS
> Middlesex University
--
Cheers, Ruslan.
+---------------------pure personal opinion------------------------+
RADIUS Server for OpenVMS project - www.radiusvms.com
vms-isps@dls.net - Forum for ISP running OpenVMS
Mobile: +7 (901) 971-3222
TKD (WTF) in Russia, St.-Petersburg - www.TaeKwonDo-WTF.SPb.RU
Thread Previous
|
Thread Next