http://qs321.pair.com?node_id=732734

dkotturi has asked for the wisdom of the Perl Monks concerning the following question:

Hi I have a small piece of code similar to the one below:
#!/usr/bin/perl package main; use strict; use warnings; my $obj = test2->new(); $obj->get_name; $obj->get_namer; package test2; sub new { my $class = shift; my $self = { lib => undef}; bless($self,$class); my $lib = test1->new(); ($self->{lib}) = ($lib->print_name()); return $self; } sub get_name { my $self = shift; return $self->{lib}->print_name(); } sub get_namer { my $self = shift; return $self->{lib}->print_namer(); } package test1; sub new { my $class = shift; my $self = {}; bless($self,$class); return $self; } sub print_name { my $self = shift; print "From test1","\n"; } sub print_namer { my $self = shift; print "Here is another namer","\n"; }

The above code is saved into a file called 'll.pl'. When I execute the above code as './ll.pl', I get the following message
From test1 Can't call method "print_name" without a package or object reference a +t ./ll.pl line 27.

can you please help me understand what I am doing wrong?

Best Regards,
Dayle Kotturi.