in reply to Turning a sub inside out
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.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();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Turning a sub inside out
by jepri (Parson) on Mar 23, 2002 at 04:37 UTC | |
by shotgunefx (Parson) on Mar 23, 2002 at 04:40 UTC |