FOR EXAMPLE:
use Data::Hash::Flatten;
# NESTED DATA
my $a = { bill => { '5/27/96' => { 'a.dat' => 1, 'b.txt' => 2,
'c.lsp' => 3 } },
jimm => { '6/22/98' => { 'x.prl' => 9, 'y.pyt' => 8,
'z.tcl' => 7 } } } ;
my @a = Data::Hash::Flatten->this($a, [qw(name date file)]);
use Data::Dumper;
print Dumper(\@a);
# FLATTENED DATA
$VAR1 = [
{
'date' => '6/22/98',
'name' => 'jimm',
'file' => 'z.tcl'
},
{
'date' => '6/22/98',
'name' => 'jimm',
'file' => 'y.pyt'
},
{
'date' => '6/22/98',
'name' => 'jimm',
'file' => 'x.prl'
},
{
'date' => '5/27/96',
'name' => 'bill',
'file' => 'c.lsp'
HERE'S ANOTHER EXAMPLE:
@ary = (@a,@b,@c);
All three arrays are not nested into @ary, but flattened into @ary.
TO SUMMARIZE:
flatten means something particular to Perl 5 users and the usage of
the term "flatten" in http://dev.perl.org/perl6/synopsis/S06.html
has no relation to its previously understood meaning.
A more accurate term might be generated or reified, because the
abstract, existent-only-in-conception list members are
concretized/generated/reified via slurping.
SUGGESTIONS:
Change this
<quote>
Slurpy parameters are treated lazily -- the list is only flattened
into an array when individual elements are actually accessed:
@fromtwo = tail(1..Inf); # @fromtwo contains a lazy [2..Inf]
</quote>
To this:
<quote>
Slurpy parameters are treated lazily -- the list is only
concretized/generated/realized/reified/actualized
into an array when individual elements are actually accessed:
@fromtwo = tail(1..Inf); # @fromtwo contains a lazy [2..Inf]
</quote>
Change this:
<quote>
Flattening argument lists
</quote>
to this:
<quote>
Actualizing argument lists
</quote>
That is not how "flatten" is used in the Camel book.
: HERE'S ANOTHER EXAMPLE:
:
: @ary = (@a,@b,@c);
:
: All three arrays are not nested into @ary, but flattened into @ary.
That *is* how "flatten" is used in the Camel book.
: TO SUMMARIZE:
:
: flatten means something particular to Perl 5 users and the usage of
: the term "flatten" in http://dev.perl.org/perl6/synopsis/S06.html
: has no relation to its previously understood meaning.
I beg your pardon. It's exactly the same as the Camel usage, except
lazy, and the laziness doesn't change the abstract flattening aspect
of it at all, only the timing of it.
: A more accurate term might be generated or reified, because the
: abstract, existent-only-in-conception list members are
: concretized/generated/reified via slurping.
:
:
: SUGGESTIONS:
:
: Change this
:
: <quote>
: Slurpy parameters are treated lazily -- the list is only flattened
: into an array when individual elements are actually accessed:
:
: @fromtwo = tail(1..Inf); # @fromtwo contains a lazy [2..Inf]
:
: </quote>
:
: To this:
:
: <quote>
: Slurpy parameters are treated lazily -- the list is only
: concretized/generated/realized/reified/actualized
: into an array when individual elements are actually accessed:
:
: @fromtwo = tail(1..Inf); # @fromtwo contains a lazy [2..Inf]
:
: </quote>
:
:
: Change this:
:
: <quote>
: Flattening argument lists
: </quote>
:
: to this:
:
: <quote>
: Actualizing argument lists
: </quote>
'Druther not. One man's accuracy is another man's obscurity. This
sense of flattening has a long history in Perl culture; I expect I'll
continue to use it that way whenever I think it's the best metaphor.
Larry