dkotturi has asked for the wisdom of the Perl Monks concerning the following question:
#!/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"; }
From test1 Can't call method "print_name" without a package or object reference a +t ./ll.pl line 27.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with OO perl
by kyle (Abbot) on Dec 27, 2008 at 02:37 UTC | |
|
Re: Need help with OO perl
by borisz (Canon) on Dec 27, 2008 at 02:23 UTC | |
by almut (Canon) on Dec 27, 2008 at 02:37 UTC | |
|
Re: Need help with OO perl
by xhunter (Sexton) on Dec 27, 2008 at 22:04 UTC |