|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: learning perl chapter 4by davido (Bishop) |
| on Jan 03, 2013 at 04:46 UTC ( #1011394=note: print w/ replies, xml ) | Need Help?? |
|
Move "my( $fred, $barney );" into the subroutine, and assign the parameter list to it, like this:
The issue is that you're never unpacking any arguments inside of the sub, so $fred and $barney are never assigned a value. The other problem is that currently $fred and $barney are being declared at the wrong scope. To avoid confusing behavior, your subroutine ought to also be returning a value explicitly, rather than relying on the behavior of returning the value of the last expression to be evaluated. It will work, but I never like seeing return values being created inside of an if/else block without explicitly using "return" as a visual cue of what's going on. Dave
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||