Class::Accessor::Contextual - Context-aware accessors
package Farm; use base qw/Class::Accessor::Contextual/; Farm->mk_accessors(qw/animals names/); my $farm = Farm->new(); $farm->animals([qw/horse pig owl/]); print join ' ', $farm->animals; # horse pig owl $farm->names({ horse => "Mr. Ed", pig => "Miss Piggy", owl => "Dr. Who"}); my %name_hash = $farm->names;
This class overrides Class::Accessor's get() method so that references to arrays or hashes will automatically be dereferenced when called in list context.
Brian Duggan, <bduggan at matatu.org>
<bduggan at matatu.org>
Class::Accessor
Copyright 2009 Brian Duggan.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Class::Accessor::Contextual, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Accessor::Contextual
CPAN shell
perl -MCPAN -e shell install Class::Accessor::Contextual
For more information on module installation, please visit the detailed CPAN module installation guide.