|
|
| Perl-Sensitive Sunglasses | |
| PerlMonks |
Re: Please helpby tobyink (Prior) |
| on Mar 27, 2012 at 16:58 UTC ( #961981=note: print w/ replies, xml ) | Need Help?? |
|
Here's how I'd do it...
... but don't submit that as-is. Learn from it and write your own. The chop() function I only use once here, to remove the line-break character from the user input. chop not only tells you what the last character was in the string, it also modifies the string! Thus your comparison at the end will never work, because by the time you've chopped $user nine times, it'll be empty. (Plus comparing an array and a string using "==" doesn't do what you seem to think it will do.) Here's a version somewhat closer in spirit to your version:
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
|
|
||||||||||||||||||||||||||||