Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This is the output of the script.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";
How do I execute the different methods in the Hi.pm package?hello REF(0x9fb3bdc) CODE(0x9fd3208)this is me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Noob OO Question
by ikegami (Patriarch) on Jun 07, 2010 at 21:45 UTC | |
|
Re: Noob OO Question
by JavaFan (Canon) on Jun 07, 2010 at 22:02 UTC | |
|
Re: Noob OO Question
by Anonymous Monk on Jun 07, 2010 at 22:28 UTC | |
by bluescreen (Friar) on Jun 07, 2010 at 23:20 UTC | |
by Anonymous Monk on Jun 07, 2010 at 23:52 UTC | |
by JavaFan (Canon) on Jun 08, 2010 at 00:01 UTC | |
by Anonymous Monk on Jun 08, 2010 at 00:12 UTC | |
| |
|
Re: Noob OO Question
by Anonymous Monk on Jun 08, 2010 at 00:16 UTC | |
|
Re: Noob OO Question
by bichonfrise74 (Vicar) on Jun 08, 2010 at 18:37 UTC | |
|
Re: Noob OO Question
by Anonymous Monk on Jun 08, 2010 at 05:44 UTC |