in reply to Re^2: Ceiling elements of an array!
in thread Ceiling elements of an array!

(the module “in the middle” will be called twice)

Assuming the above is what is wanted (always an even number of calls), another approach (including efforts of others):

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -e "my @modules = qw(zero one two three four five six seven); ;; while (@modules) { dd \@modules; my $n = $#modules / 2; print qq{@modules[ 0 .. $n ] -- @modules[ -$n-1 .. -1 ] \n\n}; pop @modules; } " ["zero", "one", "two", "three", "four", "five", "six", "seven"] zero one two three -- four five six seven ["zero", "one", "two", "three", "four", "five", "six"] zero one two three -- three four five six ["zero", "one", "two", "three", "four", "five"] zero one two -- three four five ["zero", "one", "two", "three", "four"] zero one two -- two three four ["zero", "one", "two", "three"] zero one -- two three ["zero", "one", "two"] zero one -- one two ["zero", "one"] zero -- one ["zero"] zero -- zero

Update: Added '--' marker to output to make partitioning clearer.


Give a man a fish:  <%-(-(-(-<