start page | rating of books | rating of authors | reviews | copyrights

Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: 8.31 CGI::Switch Chapter 8
Standard Modules
Next: 8.33 Config
 

8.32 Class::Struct

Formerly named Class::Template; exports a single function, struct . struct takes a list of element names and types, and optionally a class name, and creates a Perl class that implements a "struct-like" data structure. It also creates a constructor method, new , for creating objects of the class (so a class created this way must not itself define a new method).

Each element in the struct data has an accessor method, which is used to assign to the element and to fetch its value. The default accessor can be overridden by declaring a sub of the same name in the package. Each element's type can be scalar, array, hash, or class.


Previous: 8.31 CGI::Switch Perl in a Nutshell Next: 8.33 Config
8.31 CGI::Switch Book Index 8.33 Config