in reply to Turning a sub inside out

Do files and a chunk of XML have a 1-1 mapping?
You could try using closures like so. (Untested)
sub make_iterative (\@) { my $count = 0; my $arrayref = shift; return sub { return $count < @$arrayref ? undef : $arrayref->[$count++] +; }; } my @files = get_files(); my $iter = make_iterative(@files); print xml_header(); while (my $el = $iter->()){ print Chunk2XML($el); } print xml_footer();
Using closures , you can probably fit it into your framework. I just used print because I'm not exactly sure what you're doing codewise.

-Lee

"To be civilized is to deny one's nature."

Replies are listed 'Best First'.
Re: Re: Turning a sub inside out
by jepri (Parson) on Mar 23, 2002 at 04:37 UTC
    That's quite cool. The 'print' actually turns into a 'return' because HTTP::Daemon will take a function reference as contents for a HTTP return object, and then keep calling that function ref until it gets an undef. This is a much better form of the solution than the one I had in mind. Thanks!

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

      You're welcome. The more I use closures, the more I like them. It's a bit to swallow but if you haven't already check out Why I like Functional Programming

      -Lee

      "To be civilized is to deny one's nature."