|
|
| XP is just a number | |
| PerlMonks |
Re: Recursive function always returns 0by liverpole (Monsignor) |
| on Feb 14, 2007 at 18:46 UTC ( [id://600034]=note: print w/replies, xml ) | Need Help?? |
|
Hi jpfarmer,
imp's answer is correct. The whole point of recursion is, of course, that you have to propogate the answer back up the stack. In your case, you were discarding the return value from unpack_row, so the calling subroutine (also unpack_row) didn't get anything to work with. Here's a more-or-less working version of your code. Note the return statement in the if(ref($hash) eq 'HASH') block. You may have to modify what you're returning; as I'm not exactly sure what you're trying to do.
I'll point out that you don't need prototypes; just leave off the parentheses "( ... )" when you define the subroutine unpack_row and you'll be all set. Also, you don't need to shift @_; @_ is the thing shifted by default. s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||