in reply to Re^2: Expanding / flattening a structure
in thread Expanding / flattening a structure

Maybe:
# example structure my $struct = { fruit => [qw( apple pear )], type => [qw( farmed organic )], period => { 20050824 => [ to => ['new york', 'london' ], ], 20050825 => [ to => ['auckland' ], ], }, };
Would be syntactically valid?

But given the only attribute to the date is to, why not remove that layer?

jdtoronto

Replies are listed 'Best First'.
Re^4: Expanding / flattening a structure
by jaa (Friar) on Aug 24, 2006 at 19:16 UTC
    two reasons for the 'to':

    1) the token 'to' names the values in the result,

    e.g. I end up with this in the expanded array of hashes:

    to => 'auckland',

    2) also, this is just an example, in reality there are more values, e.g.

    period => { 20050824 => { to => [ 'auckland', 'new york', ], transport => [ 'air', ] }, },