package Hi; use strict; use Data::Dumper; $DATA::Dumper::Deparse = 1; sub new { my ($class, %args) = @_; my $self = { method_c => sub { my ($var_c) = @_; return $var_c . 'this is me.'; }, %args, }; return bless $self, $class; } sub method_a { my ($self, %args) = @_; return $self->{test_a}; } sub method_b { my ($self, %args) = @_; return $self->{test_b}; } sub method_d { my ($self, %args) = @_; my $method_c = $self->{method_c}; my $execute_c = $method_c->($method_c); return $execute_c; } 1; ----------------------- #!/usr/bin/perl use strict; use Hi; my ($get_a, $get_b) = ('get_a', 'get_b'); my $test = new Hi( test_a => 'hello', test_b => \sub{ return 1 }, test_c => \sub{ get_me( $get_a, $get_b ) }, ); sub get_me { my ($get_a, $get_b) = @_; return $get_a . $get_b; } print $test->method_a() . "\n"; print $test->method_b() . "\n"; print $test->method_d() . "\n"; #### hello REF(0x9fb3bdc) CODE(0x9fd3208)this is me.