1MooseX::GlobRef(3) User Contributed Perl Documentation MooseX::GlobRef(3)
2
3
4
6 MooseX::GlobRef - Store a Moose object in glob reference
7
9 package My::IO;
10
11 use Moose;
12 use MooseX::GlobRef;
13
14 has 'file' => ( is => 'ro', isa => 'Str', required => 1 );
15
16 sub open {
17 my $fh = shift;
18 open $fh, $fh->file or confess "cannot open";
19 return $fh;
20 }
21
22 sub getlines {
23 my $fh = shift;
24 return readline $fh;
25 }
26
27 my $io = My::IO->new( file => '/etc/passwd' );
28 print "::::::::::::::\n";
29 print $io->file, "\n";
30 print "::::::::::::::\n";
31 $io->open;
32 print $io->getlines;
33
35 This module allows to store Moose object in glob reference of file
36 handle. The class attributes will be stored in hash slot associated
37 with glob reference. It allows to create a Moose version of
38 IO::Handle.
39
40 The attributes can be accessed directly with following expression:
41
42 my $hashref = \%{*$self};
43 print $hashref->{key};
44
45 or shorter:
46
47 print *$self->{key};
48
49 but the standard accessors should be used instead:
50
51 print $self->key;
52
54 init_meta( args : Hash ) : Moose::Meta::Class
55 See Moose::Exporter.
56
58 Moose.
59
61 Piotr Roszatycki <dexter@cpan.org>
62
64 Copyright (C) 2007, 2008, 2009 by Piotr Roszatycki <dexter@cpan.org>.
65
66 This program is free software; you can redistribute it and/or modify it
67 under the same terms as Perl itself.
68
69 See <http://www.perl.com/perl/misc/Artistic.html>
70
71
72
73perl v5.12.0 2010-05-13 MooseX::GlobRef(3)