Name : perl-Tie-OneOff
| |
Version : 1.03
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.6.1
| Date : 2023-07-20 19:31:47
|
Group : Development/Libraries/Perl
| Source RPM : perl-Tie-OneOff-1.03-lp155.6.1.src.rpm
|
Size : 0.01 MB
| |
Packager : https://www_suse_com/
| |
Summary : create tied variables without defining a separate package
|
Description :
The Perl tie mechanism ties a Perl variable to a Perl object. This means that, conventionally, for each distinct set of tied variable semantics one needs to create a new package. The package symbol table then acts as a dispatch table for the intrinsic actions (such as \'FETCH\', \'STORE\', \'FETCHSIZE\') that can be performed on Perl variables.
Sometimes it would seem more natural to associate a dispatch table hash directly with the variable and pretend as if the intermediate object did not exist. This is what \'Tie::OneOff\' does.
It is important to note that in this model there is no object to hold the instance data for the tied variable. The callbacks in the dispatch table are called not as object methods but as simple subroutines. If there is to be any instance information for a variable tied using \'Tie::OneOff\' it must be in lexical variables that are referenced by the callback closures.
\'Tie::OneOff\' does not itself provide any default callbacks. This can make defining a full featured hash interface rather tedious. To simplify matters the element \'BASE\' in the dispatch table can be used to specify a \"base object\" whose methods provide the default callbacks. If a reference to an unblessed Perl variable is specified as the \'BASE\' then the variable is blessed into the appropriate \'Tie::StdXXXX\' package. In this case the unblessed variable used as the base must, of course, be of the same type as the variable that is being tied.
In \'make_counter()\' in the synopsis above, the variable \'$i\' gets blessed into \'Tie::StdScalar\'. Since there is no explict STORE in the dispatch table, an attempt to store into a counter is implemented by calling \'(\\$i)->STORE(AATT_)\' which in turn is resolved as \'Tie::StdScalar::STORE(\\$i,AATT_)\' which in turn is equivalent to \'$i=shift\'.
Since many tied variables need only a \'FETCH\' method \'Tie::OneOff\' ties can also be specified by giving a simple code reference that is taken to be the variable\'s \'FETCH\' callback.
For convience the class methods \'scalar\', \'hash\' and \'array\' take the same arguments as the tie inferface and return a reference to an anonymous tied variable. The class method \'lvalue\' is like \'scalar\' but returns an lvalue rather than a reference.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/15.5/noarch |