Name : perl-Attribute-Types
| |
Version : 0.10
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp154.9.1
| Date : 2023-01-27 18:38:49
|
Group : Development/Libraries/Perl
| Source RPM : perl-Attribute-Types-0.10-lp154.9.1.src.rpm
|
Size : 0.02 MB
| |
Packager : https://www_suse_com/
| |
Summary : Attributes that confer type on variables
|
Description :
The Attribute::Types module provides 10 universally accessible attributes that can be used to create variables that accept assignments of only specific types of data.
The attributes are:
* \'INTEGER\'
Indicates that the associated scalar, or the elements of the associated array, or the entries of the associated hash can only contain integer values (those values that are internally represented as actual numbers (or may be converted to actual numbers without generating a warning), and for which \'int($value)==$value)\'.
The attribute may also be specified with a range of integer values, indicating a further restriction on the values the associated variable can store. For example:
my $x1 : INTEGER(1..100); # Any int between 1 and 100 my $x2 : INTEGER(-10..10); # Any ine between -10 and 10 my $x3 : INTEGER(0..); # Any positive int my $x4 : INTEGER(..99); # Any int < 100 (including negatives)
* \'NUMBER\'
Indicates that the associated scalar, or the elements of the associated array, or the entries of the associated hash can only contain values that are internally represented by (or silently convertible to) valid Perl numbers.
The attribute may also be specified with a range of numerical values, indicating a further restriction on the values the associated variable can store. For example:
my $x1 : NUMBER(1.0..100.0); # Any number between 1 and 100 my $x2 : NUMBER(-10..10); # Any number between -10 and 10 my $x3 : NUMBER(0..); # Any positive number my $x4 : NUMBER(..99.9); # Any number < 99.9 (incl. negatives)
* \'SCALAR\'
Indicates that the associated scalar, or the elements of the associated array, or the entries of the associated hash can only contain references to scalars (i.e. only values for which \'ref($value) eq \'SCALAR\'\').
* \'ARRAY\'
Indicates that the associated variable can only contain references to arrays (i.e. only values for which \'ref($value) eq \'ARRAY\'\').
* \'HASH\'
Indicates that the associated variable can only contain references to hashes (i.e. only values for which \'ref($value) eq \'HASH\'\').
* \'CODE\'
Indicates that the associated variable can only contain references to subroutines (i.e. only values for which \'ref($value) eq \'CODE\'\').
* \'GLOB\'
Indicates that the associated variable can only contain references to typeglobs (i.e. only values for which \'ref($value) eq \'GLOB\'\').
* \'REF\'
Indicates that the associated variable can only contain references to other references (i.e. only values for which \'ref($value) eq \'REF\'\').
* \'REGEX\'
Indicates that the associated variable can only contain references to precompiled regular expressions (i.e. only values for which \'ref($value) eq \'Regexp\'\').
* \'Type\'
Used to specify class-wise or generic storage constraints on a variable. There are three permitted syntaxes:
* \'Type(Class::Name)\'
Indicates that the associated variable can only contain references to objects belonging to the specified class, or to one of its derived classes.
* \'Type(/pattern/)\'
Indicates that the associated variable can only contain values that successfully match the specified pattern.
* \'Type(&subname)\'
Indicates that the associated variable can only contain values for which the specified subroutine returns true when passed the value as its first argument.
Note that anonymous subroutines cannot be used in this context (they are run-time phenomena and types have to be set up at compile-time).
If the module is imported with a list of attribute names:
use Attribute::Types qw(INTEGER HASH);
then only those attributes can be used to specify types.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-A/15.4/noarch |