My first piece of advice is to stop using prototypes. Prototypes in Perl do not do what you think, and what they do in most cases is something you really don't want. The (unfortunately now MIA, so go to the wayback machine) article FMTYEWTK about Prototypes in Perl explains this in great detail.
Of course you've avoided most of the pain by using method calls, which causes the prototype to be ignored. Thereby they serve no purpose other than to confuse the maintenance programmer.
Another general tip is that it is generally good programming style to declare lexical variables as close to their scope as possible. So move your declarations in.
Error handling. Rather than return errors, I prefer throwing an exception with die. That way if someone forgets to have error handling you still know that things went wrong. (Opinions differ on this.)
A more relevant tip is that you shouldn't rewrite code without a reason. You have code. It works. A rewrite takes effort and may not work. So why do it?
Now let's look at your rewrite. You say you're trying to follow the advice in Higher Order Perl. I'd take that to mean that you're interested in doing things like having lazy lists. If you want to do that, then you need to start your rewrite from the inside out. So you want to start your rewrite with get_entries. So you'd want to have a function named something like get_entries_iterator that returns a function that you can call to get each entry in turn. And then you'd call it repeatedly to get each entry.
My second response to Re: Let's get lazy should give you a sense of what this could look like.
In reply to Re: Advice on transforming a sub into a re-entrant recursive-able method.
by tilly
in thread Advice on transforming a sub into a re-entrant recursive-able method.
by hechz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |