Think about Loose Coupling | |
PerlMonks |
Re: newbie's question on inheritanceby tobyink (Canon) |
on Oct 28, 2012 at 06:43 UTC ( [id://1001251]=note: print w/replies, xml ) | Need Help?? |
For this to work, you need new to return an object. Right now it just returns undef. Firstly, you need to read perlsub to learn how subs work, and the important difference between $_ and @_. Then turn to perlootut to learn the basics of object-oriented programming in Perl. Here's how you could write your code...
But personally I'd write it as...
Either way, read those bits of Perl documentation I mentioned, and learn why your original attempt is wrong.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|