A complex data structure
Here is a script named
hoh.t
taken from the
perldsc(1) man page and then compacted to hide the structure:
%TV=(flintstones=>{series=>"flintstones",nights=>[qw(monday thursday friday)],
members=>[{name=>"fred",role=>"lead",age=>36,},{name=>"wilma",role=>"wife",
age=>31,},{name=>"pebbles",role=>"kid",age=>4,},],},jetsons=>{series=>"jetsons",
nights=>[qw(wednesday saturday)],members=>[{name=>"george",role=>"lead",age=>41,
},{name=>"jane",role=>"wife",age=>39,},{name=>"elroy",role=>"kid",age=>9,},],},
simpsons=>{series=>"simpsons",nights=>[qw(monday)],members=>[{name=>"homer",
role=>"lead",age=>34,},{name=>"marge",role=>"wife",age=>37,},{name=>"bart",
role=>"kid",age=>11,},],},);
The command perltidy hoh.t
produces a file named
hoh.t.tdy
with this result:
%TV = (
flintstones => {
series => "flintstones",
nights => [qw(monday thursday friday)],
members => [
{
name => "fred",
role => "lead",
age => 36,
},
{
name => "wilma",
role => "wife",
age => 31,
},
{
name => "pebbles",
role => "kid",
age => 4,
},
],
},
jetsons => {
series => "jetsons",
nights => [qw(wednesday saturday)],
members => [
{
name => "george",
role => "lead",
age => 41,
},
{
name => "jane",
role => "wife",
age => 39,
},
{
name => "elroy",
role => "kid",
age => 9,
},
],
},
simpsons => {
series => "simpsons",
nights => [qw(monday)],
members => [
{
name => "homer",
role => "lead",
age => 34,
},
{
name => "marge",
role => "wife",
age => 37,
},
{
name => "bart",
role => "kid",
age => 11,
},
],
},
);