|
|
|
Your skill will accomplish what the force of many cannot |
|
| PerlMonks |
Re: How am i doing?by cavac (Prior) |
| on Jul 21, 2025 at 13:24 UTC ( [id://11165740]=note: print w/replies, xml ) | Need Help?? |
|
Overall, a good start. The main some problems that i see:
Here is a version i quickly "modernized" and "cavacized". I'm note sure if the result is correct, though, since i don't have the description in the book available (and i had only a few minutes during my afternoon break to write this).
Basically, i replaced the recursion with a while loop, added modern sub-signatures, made sure the "frame" we are working on is passed through the function calls (instead of global vars). And removed/inlined the count() function because it's a single if-statement that doesn't warrant the performance overhead of a funtion call. And, oh, added an example of Data::Dumper to show how you can easily look at complex data structures for debugging. I also moved the main code above the subs, because that makes it easier if you come back at a later time to the code. The high level stuff is at the beginning (showing/explaining what the script does), the nitty-gritty details that you might never have to touch again are below that. Hope that helps.
PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP Also check out my sisters artwork and my weekly webcomics
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||