use strict; use warnings; {package Object::Tiny;} {package Foo; use parent -norequire ,"Object::Tiny"; Object::Tiny::->import( qw|bar baz headers myhash|); } my $f = Foo::->new(bar=>44, baz=>"Value of baz"); $f->headers_set(["This is H-1","This is H-2"]); # SETTER - sets arrayref print "Object f Scalar: $_=> ",$f->$_,";\n" for qw |baz bar |; # Get a callback for each member of array ref: $f->headers_forEach(sub{print "Object f :(Array component) header=$_[0];\n"}); $f->baz_forEach(sub{print "Object f : (Scalar accessed as array) baz value=$_[0];\n"}); $f->myhash_set({Uno=>"One", Dos=>"Two", Tres=>"Three"}); # Setter - sets hashref # Get a callback for each KEY. # Extra parameters (R/W) returned are the extra param passed to forEach() $f->myhash_forEach(sub{print "Object f (HashRef): myhash KEY:$_[0]; VALUE:$_[1]; Extra args($_[2],", ++$_[3],")\n"}, "Extra-arg1", 25);