MooseX...:Object(3pm)
π NAME π
MooseX::GlobRef::Role::Object β bestie, it's a role for MooseX::GlobRef that lets you be an object and a filehandle at the same time π¦
(also hi, this is a User Contributed Perl Documentation page, section 3pm, filed under MooseX...:Object(3pm) because the man page title got a lil truncated and honestly? iconic.)
β¨ SYNOPSIS β¨
Moose::Util::MetaRole::apply_base_class_roles(
for_class => $caller,
roles => [ 'MooseX::GlobRef::Role::Object' ],
);
package My::IO::File;
use Moose;
extends 'Moose::Object', 'IO::File';
with 'MooseX::GlobRef::Role::Object';
has 'file' => ( is => 'ro', isa => 'Str', required => 1 );
has 'mode' => ( is => 'ro', isa => 'Str', default => 'r' );
sub BUILD {
my ($fh) = @_;
$fh->open( $fh->file, $fh->mode );
};
sub slurp {
my ($fh) = @_;
local $/ = undef;
return $fh->getline;
};
my $io = My::IO::File->new( file => '/etc/passwd' );
print "::::::::::::::\n";
print $io->file, "\n";
print "::::::::::::::\n";
print $io->slurp;
like, look at that. an object that is a glob ref. main character energy fr π
πΈ DESCRIPTION πΈ
okay so. this is a role for Moose::Object that gets applied by MooseX::GlobRef. what it does is let you store a Moose object inside the glob reference of a file handle. yes really. object brain, filehandle body. it's giving duality π«Ά
now, if you're building straight-up Moose classes, you should be using the MooseX::GlobRef package instead, no cap. but β and this is the tea β β MooseX::GlobRef::Role::Object is genuinely the move when you want to extend non-Moose classes like IO::File or File::Temp. those cuties aren't Moose, so you can't just inherit the whole thing. you need the role. iykyk π
π METHODS π
<<around>> dump( maxdepth : Int = 1 ) : Array|Str
so this one is wrapped in an around modifier β¨ it dumps the object itself plus a hash slot of the glob reference of this object. two for one, we love a bonus.
the return value is an Array or a Str β depended on context, so watch your scalar vs list vibes π
go peek at Moose::Object for the full lore on how this works π¦
π SEE ALSO π
MooseX::GlobRefπMoose::ObjectπΈMoose::Roleβ¨
π§ AUTHOR π§
Piotr Roszatycki <dexter@cpan.org> β legend behavior, honestly π
π LICENSE π
Copyright (c) 2007, 2008, 2009, 2010 Piotr Roszatycki <dexter@cpan.org>.
this is free software; you can redistribute it and/or modify it under the same terms as perl itself. periodt π
see <http://dev.perl.org/licenses/artistic.html> for the receipts π₯
and that's the whole page bestie!! πβ¨
this was perl v5.42.0, dated 2025-07-25, from that MooseX...:Object(3pm) page in User Contributed Perl Documentation β mwah, go read some source code, ily ππ¦πΈ
π¦ where this page comes from
- fedora 43: perl-MooseX-GlobRef 0.0701-41.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms