in reply to flattening a list-of-lists
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; }
|
|---|