sub flatten { my %seen; my @temp = @_; for (my $i=0; $i < @temp; $i++){ if ( UNIVERSAL::isa($temp[$i], 'ARRAY') ){ die "Circular reference! Bailing..." if $seen{$temp[$i]}++; splice (@temp, $i, 1, @{$temp[$i]} ) } } return wantarray ? @temp : \@temp; }
In reply to Re: flattening, No recursion
by shotgunefx
in thread flattening a list-of-lists
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |