I have thought about a bruteforce method to flatten a deeply nested list with Data::Dumper, by massaging the output of Data::Dumper. It doesn't have any recursion (at least not in my perl script), and all that's needed is a simple regular expression to strip out unwanted stuff. I have quickly wrote the follow code to prove that it can be done. Forget about the performance of this method, it's just a proof of concept. :-)
#!/usr/local/bin/perl -w
use strict;
use Data::Dumper;
my @arr = ([1,2],[3,4,[5,6]],7);
my $list = flatten(\@arr);
print Dumper($list);
sub flatten
{
my $data = Dumper(shift);
$data =~ s/(\$\w+\s+=\s+)|[\n\[\];]//gm; # massage the output
return [eval "$data"];
}
And the output is as expected -
$VAR1 = [
1,
2,
3,
4,
5,
6,
7
];