nedals has asked for the wisdom of the Perl Monks concerning the following question:
I can up with this simplfied snippet to build the structure but I'm getting an unexpected reference to an undefined value and it's not getting all the values.$OUTER_Ref = [ { 'INNER' => [ { 'DATA' => 'data01' }, { 'DATA' => 'data02' }, ] }, { 'INNER' => [ { 'DATA' => 'data11' }, { 'DATA' => 'data12' }, ] }, ];
use strict; use Data::Dumper; my @outer = (); my @inner = (); my $n = 0; while (<DATA>) { chomp; push @inner, { DATA => $_ }; if ($n == 1) { push @outer, { 'INNER' => @inner }; @inner = (); $n = 0; } else { $n++; } } print Dumper(\@outer); __DATA__ data01 data02 data11 data12
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Nested LOOP in HTML::Template
by bmann (Priest) on May 10, 2005 at 23:41 UTC | |
|
Re: Nested LOOP in HTML::Template
by moot (Chaplain) on May 10, 2005 at 22:25 UTC | |
by nedals (Deacon) on May 10, 2005 at 22:34 UTC | |
|
Re: Nested LOOP in HTML::Template
by shemp (Deacon) on May 10, 2005 at 22:27 UTC |