H
Himanshu Garg
Dear Perl Programmers,
I tried out the code given in :-
http://www.perldoc.com/perl5.8.0/pod/perltoot.html#Aggregation
The following line :-
printf "%s is really %s.\n", $him->name, $him->fullname;
gives the following output :-
Tommy is really Fullname=HASH(0x804c9b8).
This happens because fullname returns an object reference as follows :-
sub fullname
{
my $self = shift;
return $self->{FULLNAME};
}
Therefore the line should probably be :-
printf "%s is really %s.\n", $him->name, $him->fullname->as_string;
Please correct me if I am wrong.
Thank You
Himanshu.
I tried out the code given in :-
http://www.perldoc.com/perl5.8.0/pod/perltoot.html#Aggregation
The following line :-
printf "%s is really %s.\n", $him->name, $him->fullname;
gives the following output :-
Tommy is really Fullname=HASH(0x804c9b8).
This happens because fullname returns an object reference as follows :-
sub fullname
{
my $self = shift;
return $self->{FULLNAME};
}
Therefore the line should probably be :-
printf "%s is really %s.\n", $him->name, $him->fullname->as_string;
Please correct me if I am wrong.
Thank You
Himanshu.