Class::Accessor::Array::Glob - Generate accessors/constructor for array-based object (supports globbing attribute)


This document describes version 0.01 of Class::Accessor::Array::Glob (from Perl distribution Class-Accessor-Array-Glob), released on 2016-03-29.


In lib/Your/

 package Your::Class;
 use Class::Accessor::Array::Glob {
     accessors => {
         foo => 0,
         bar => 1,
         baz => 2,
     glob_attribute => 'baz',

In code that uses your class:

 use Your::Class;

 my $obj = Your::Class->new;

$obj is now:

 bless([1, 2, 3, 4, 5], "Your::Class");


This module is a builder for array-backed classes. It is the same as Class::Accessor::Array except that you can define your last (in term of the index in array storage) attribute to be a "glob attribute", meaning it is an array where its elements are stored as elements of the array storage. There can be at most one glob attribute and it must be the last.

Note that without a glob attribute, you can still store arrays or other complex data in your attributes. It's just that with a glob attribute, you can keep a single flat array backend, so the overall number of arrays is minimized.

An example of application: tree node objects, where the first attribute (array element) is the parent, then zero or more extra attributes, then the last attribute is a globbing one storing zero or more children. This is how Mojo::DOM stores its HTML tree node, for example.


Please visit the project's homepage at


Source repository is at


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


Other class builders for array-backed objects: Class::Accessor::Array, Class::XSAccessor::Array, Class::ArrayObjects, Object::ArrayType::New.


perlancar <>


This software is copyright (c) 2016 by

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.