in reply to stack array to array of arrays

G'day spandox,

Not recommended for production code. :-)

#!/usr/bin/env perl use strict; use warnings; use Data::Dump; my @a = qw{a b c e 1 2 3 4 5 3 f}; my $x = 3; dd [(map{@;==$x?do{$;=[@;];@;=($_);$;}:do{push(@;,$_);()}}@a),[@;]];

Output:

[["a", "b", "c"], ["e", 1, 2], [3, 4, 5], [3, "f"]]

[P.S. With "my @a = ();", the output is "[[]]".]

-- Ken