MooseX::GlobRef::Object - Store a Moose object in glob reference
package My::IO; use Moose; extends 'MooseX::GlobRef::Object'; has 'filename' => ( is => 'ro', isa => 'Str', required => 1 ); sub open { my $fh = shift; my $hashref = ${*$fh}; open $fh, $hashref->{filename} or confess "cannot open"; return $fh; } sub getlines { my $fh = shift; return readline $fh; } my $io = new My::IO filename=>'/etc/passwd'; print "::::::::::::::\n"; print $io->filename, "\n"; print "::::::::::::::\n"; $io->open; print $io->getlines;
This meta-policy allows to store Moose object in glob reference or file handle. The class attributes will be stored in anonymous hash associated with glob reference. It allows to create a Moose version of IO::Handle.
The elements of hash can be accessed with ${*$self}->{key} expression.
You can use MooseX::GlobRef::Meta::Instance metaclass directly if you need more customised configuration.
Moose::Object
MooseX::GlobRef::Meta::Instance, MooseX::GlobRef::Meta::Class, Moose, metaclass.
Piotr Roszatycki <dexter@debian.org>
Copyright (C) 2007 by Piotr Roszatycki <dexter@debian.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install MooseX::GlobRef::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::GlobRef::Object
CPAN shell
perl -MCPAN -e shell install MooseX::GlobRef::Object
For more information on module installation, please visit the detailed CPAN module installation guide.