I think you're failing to see it because you're unclear on what you wish to accomplish. That also makes it hard to give you a good answer. So I'll settle for giving good advice, and some of it may pertain.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.