in reply to Re^5: how to let sub return hash of 2 sub?
in thread how to let sub return hash of 2 sub?

I wasn't aware that they could create anonymous classes, and I'm not seeing the advantage of
{ package NameValTuple; use Moose; has name => ( is => 'rw' ); has val => ( is => 'rw' ); no Moose; __PACKAGE__->meta->make_immutable; }
over
{ package NameValTuple; sub new { my $class = shift; bless({ @_ }, $class) } sub name { $_[0]->{name} } sub val { $_[0]->{val} } }

Replies are listed 'Best First'.
Re^7: how to let sub return hash of 2 sub?
by Anonymous Monk on May 30, 2015 at 21:15 UTC

    Fair point; if the OP only needs to write a couple of classes by hand that's fine. If he ends up needing to write more classes than that, perhaps some with inheritance etc., learning and using one of the Perl OO frameworks should show its advantages pretty quickly.