VMS::DCLsym - Perl extension to manipulate DCL symbols
tie %allsyms, VMS::DCLsym; tie %cgisyms, VMS::DCLsym, 'GLOBAL';
$handle = new VMS::DCLsyms; $value = $handle->getsym($name); $handle->setsym($name,$value,'GLOBAL') or die "Can't create symbol: $!\n"; $handle->delsym($name,'LOCAL') or die "Can't delete symbol: $!\n"; $handle->clearcache();
The VMS::DCLsym extension provides access to
DCL symbols using a tied hash interface. This allows
Perl scripts to manipulate symbols in a manner similar to the way in which
logical names are manipulated via the built-in
%ENV hash. Alternatively, one can call methods in this package directly to read,
create, and delete symbols.
This interface lets you treat the
DCL symbol table as a Perl associative array, in which the key of each element is the symbol name, and the value of the element is that symbol's value. Case is not significant in the key string, as
DCL converts symbol names to uppercase, but it is significant in the value string. All of the usual operations on associative arrays are supported. Reading an element retrieves the current value of the symbol, assigning to it defines a new symbol (or overwrites the old value of an existing symbol), and deleting an element deletes the corresponding symbol. Setting an element to
undef, or undefing it directly, sets the corresponding symbol to the null string. You may also read the special keys
':LOCAL' to find out whether a default symbol table has been specified for this hash (see
below), or set either or these keys to specify a default symbol table.
When you call the tie function to bind an associative array to this package, you may specify as an optional argument the symbol table in which you wish to create and delete symbols. If the argument is the string 'GLOBAL', then the global symbol table is used; any other string causes the local symbol table to be used. Note that this argument does not affect attempts to read symbols; if a symbol with the specified name exists in the local symbol table, it is always returned in preference to a symbol by the same name in the global symbol table.
Although it's less convenient in some ways than the tied hash interface, you can also call methods directly to manipulate individual symbols. In some cases, this allows you finer control than using a tied hash aggregate. The following methods are supported:
VMS::DCLsymobject which can be used as a handle for later method calls. The single optional argument specifies the symbol table used by default in future method calls, in the same way as the optional argument to tie described above.
getsymreturns the value of the symbol whose name is given as the argument to the call, or undef if no such symbol exists. Symbols in the local symbol table are always used in preference to symbols in the global symbol table. If called in an array context,
getsymreturns a two-element list, whose first element is the value of the symbol, and whose second element is the string 'GLOBAL' or 'LOCAL', indicating the table from which the symbol's value was read.
setsymreturns TRUE if successful, and FALSE otherwise.
setsym. It returns TRUE if the symbol was successfully deleted, and FALSE if it was not.
clearcacheagain with a TRUE value as the first argument. It returns TRUE or FALSE to indicate whether caching was previously enabled or disabled, respectively.
This method is a stopgap until we can incorporate code into this extension to traverse the process' symbol table directly, so it may disappear in a future version of this package.
Charles Bailey email@example.com
The list of symbols for the iterator is assembled by spawning off a subprocess, which can be slow. Ideally, we should just traverse the process' symbol table directly from C.
If rather than formatting bugs, you encounter substantive content errors in these documents, such as mistakes in the explanations or code, please use the perlbug utility included with the Perl distribution.