J
joubertb
I have been working on this for the past few days and still can't
figure out what I am doing wrong.
Below the my test program. Can someone point out to me what I am doing
wong?
Thanks.
--joubert
===========================< cut here >===============================
package foobar;
sub new {
my $class = shift;
my $self = {};
return bless $self, $class;
}
sub func {
my $self = shift;
my $param = shift;
print "inside function\n";
print "param=$param\n";
return "zzzzz";
}
$f = new foobar;
my %myarray = (
foo => { func => $f->func, }
);
#
# When I do the above assignment, it calls the method $f->func. What I
want it to do is assign the
# function pointer to func so that below I can call it.
#
#$myarray{foo}{func};
$xxx = $myarray{foo}{func}("abc123");
#
# When the function above is called, it says that "zzzzz" is does not
exist. It looks like the return
# value from $f->func is assigned to $myarray{foo}{func}.
#
# What am I doing wrong ?
figure out what I am doing wrong.
Below the my test program. Can someone point out to me what I am doing
wong?
Thanks.
--joubert
===========================< cut here >===============================
package foobar;
sub new {
my $class = shift;
my $self = {};
return bless $self, $class;
}
sub func {
my $self = shift;
my $param = shift;
print "inside function\n";
print "param=$param\n";
return "zzzzz";
}
$f = new foobar;
my %myarray = (
foo => { func => $f->func, }
);
#
# When I do the above assignment, it calls the method $f->func. What I
want it to do is assign the
# function pointer to func so that below I can call it.
#
#$myarray{foo}{func};
$xxx = $myarray{foo}{func}("abc123");
#
# When the function above is called, it says that "zzzzz" is does not
exist. It looks like the return
# value from $f->func is assigned to $myarray{foo}{func}.
#
# What am I doing wrong ?