NAME

List::Flat - Functions to flatten a structure of array references

VERSION

This documentation refers to version 0.003

SYNOPSIS

use List::Flat(qw/flat flat_f flat_r/);

my @list = ( 1, [ 2, 3, [ 4 ], 5 ] , 6 );

my @newlist = flat_f(@list);
# ( 1, 2, 3, 4, 5, 6 )

push @list, [ 7, \@list, 8, 9 ];
my @newerlist = flat_r(@list);
# ( 1, 2, 3, 4, 5, 6, 7, 8, 9 )

my @evennewerlist = flat(@list);
# throws exception

DESCRIPTION

List::Flat is a module with functions to flatten a deep structure of array references into a single flat list.

FUNCTIONS

CONFIGURATION AND ENVIRONMENT

The functions will normally use Ref::Util to determine whether an element is an array reference or not, but if the environment variable $PERL_LIST_FLAT_NO_REF_UTIL is set to a true value, or the perl variable List::Flat::NO_REF_UTIL is set to a true value before importing it, it will use its internal pure-perl implementation.

DEPENDENCIES

It has one optional dependency, Ref::Util. If it is not present, a pure perl implementation is used instead.

SEE ALSO

There are several other modules on CPAN that do similar things.

It is certainly possible that there are others.

ACKNOWLEDGEMENTS

Ryan C. Thompson's List::Flatten::Recursive inspired the creation of the flat_r() function.

Aristotle Pagaltzis suggested throwing an exception upon seeing a circular reference rather than simply skipping it.

Mark Jason Dominus's book Higher-Order Perl was and continues to be extremely helpful and informative.

Toby Inkster contributed a patch to slightly speed up flat() and flat_r().

BUGS AND LIMITATIONS

If you bless something into a class called 'ARRAY', the pure-perl version will break. But why would you do that?

AUTHOR

Aaron Priven apriven@actransit.org

COPYRIGHT & LICENSE

Copyright 2017

This program is free software; you can redistribute it and/or modify it under the terms of either:

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.