Name : perl-Data-Struct
| |
Version : 1.701
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp156.4.1
| Date : 2024-07-03 19:03:19
|
Group : Development/Libraries/Perl
| Source RPM : perl-Data-Struct-1.701-lp156.4.1.src.rpm
|
Size : 0.01 MB
| |
Packager : https://www_suse_com/
| |
Summary : Simple struct building
|
Description :
A _struct_ is a data structure that can contain values (attributes). The values of the attributes can be set at creation time, and read and modified at run time. This module implements a very basic and easy to use _struct_ builder.
Attributes can be anything that Perl can handle. There\'s no checking on types. If you need _struct_s with type checking and inheritance and other fancy stuff, use one of the many CPAN modules that implement data structures using classes and objects. Data::Struct deals with data structures and not objects, so I placed this module under the Data:: hierarchy.
To use Data::Struct, just use it. This will export the struct() function that does all the work.
To define a structure, call struct() with the name of the structure and a list of accessors to be created:
struct( \"Foo\", \"foo\", \"bar\");
which can be nicely written as:
struct Foo => qw( foo bar );
To prevent ambiguities, defining a struct requires struct() to be called in void context.
To create an empty structure:
my $s = struct \"Foo\";
To create a structure with one or more pre-initialised attributes:
my $s = struct Foo => { foo => 3, bar => \"Hi\" };
To prevent ambiguities, creating a struct requires struct() to be called in scalar context.
When the structure has been created, you can use accessor functions to set and get the attributes:
print \"bar is \" . $s->bar . \"\ \"; # \"Hi\" $s->bar = 2; print \"bar is now \" . $s->bar . \"\ \"; # 2
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-D/15.6/noarch |