Personal tools
Skip to content. | Skip to navigation
Class::Struct module exports a single function struct(). Given a list of element names and types, and optionally a class name, struct() creates a Perl 5 class that implements a struct-like data structure.
This module offers a minimalist class construction kit in around 120 lines of code. Here is a list of features: * defines attributes via import arguments * generates read-write accessors * supports lazy attribute defaults * supports custom accessors * superclass provides a standard new constructor * new takes a hash reference or list of key/value pairs * new has heuristics to catch constructor attribute typos * new calls BUILD for each class from parent to child * superclass provides a DESTROY method * DESTROY calls DEMOLISH for each class from child to parent
Mixin to add / call inheritable triggers.
Class::XSAccessor implements fast read, write and read/write accessors in XS. Additionally, it can provide predicates such as has_foo() for testing whether the attribute foo is defined in the object. It only works with objects that are implemented as ordinary hashes. Class::XSAccessor::Array implements the same interface for objects that use arrays for their internal representation.
This module provides a clone() method which makes recursive copies of nested hash, array, scalar and reference types, including tied variables and objects. clone() takes a scalar argument and an optional parameter that can be used to limit the depth of the copy. To duplicate lists, arrays or hashes, pass them in by reference.