Re: foreach in my



thecento@xxxxxxxxx wrote:
The part that is throwing an error is:
foreach my $record (@$a_records) {
          print "         {
                'content' => $record->{host},
                'name' => $record->{name},
                'type' => 'A'
          },\n";
        };

If you copy-and-paste that to a separate script, it compiles OK. This, however, fails with a syntax error near "foreach ":

  [
  foreach my $record (@ARGV) {print "$record\n";}
  ]

Try

$r=$req->{attributes}{create_items}[0]{product_data}{zone}{records};
push @$r,{content=>$_->{host},name=$_->{name},type=>'A'} foreach @$a_records;


to populate the 'records' array after creating the structure.

Or, pre-calculate a temporary array and use a reference to that
array when building the structure.
	-Joe
.