T
thecento
Hi Folks,
I have the following block of code (at bottom of message).
The part that is throwing an error is:
foreach my $record (@$a_records) {
print " {
'content' => $record->{host},
'name' => $record->{name},
'type' => 'A'
},\n";
};
syntax error at ./Zoneparse.pl line 72, near "foreach "
Execution of ./Zoneparse.pl aborted due to compilation errors.
I assume because it's inside the my $req section.
Two questions:
1. Any idea why I get this error?
2. Will the print return the data to the $req?
Thanks!
Code:
my $req = {
'protocol' => 'TPP',
'object' => 'order',
'version' => '1.4.0',
'action' => 'create',
'attributes' => {
'contacts' => [
{
'id' => $user_contact,
}
],
'create_items' => [
{
'product_data' => {
'period' => '1',
'pool' => {
'name' => 'default',
},
'zone' => {
'records' => [
foreach my $record (@$a_records) {
print " {
'content' => $record->{host},
'name' => $record->{name},
'type' => 'A'
},\n";
};
],
'name' => $zone
}
},
'object_type' => 'managed',
'contact_set' => {
'admin' => '0',
'tech' => '0',
'billing' => '0'
},
'service' => 'dns',
'order_item_type' => 'new',
}
],
'handling' => 'process'
}
};
I have the following block of code (at bottom of message).
The part that is throwing an error is:
foreach my $record (@$a_records) {
print " {
'content' => $record->{host},
'name' => $record->{name},
'type' => 'A'
},\n";
};
syntax error at ./Zoneparse.pl line 72, near "foreach "
Execution of ./Zoneparse.pl aborted due to compilation errors.
I assume because it's inside the my $req section.
Two questions:
1. Any idea why I get this error?
2. Will the print return the data to the $req?
Thanks!
Code:
my $req = {
'protocol' => 'TPP',
'object' => 'order',
'version' => '1.4.0',
'action' => 'create',
'attributes' => {
'contacts' => [
{
'id' => $user_contact,
}
],
'create_items' => [
{
'product_data' => {
'period' => '1',
'pool' => {
'name' => 'default',
},
'zone' => {
'records' => [
foreach my $record (@$a_records) {
print " {
'content' => $record->{host},
'name' => $record->{name},
'type' => 'A'
},\n";
};
],
'name' => $zone
}
},
'object_type' => 'managed',
'contact_set' => {
'admin' => '0',
'tech' => '0',
'billing' => '0'
},
'service' => 'dns',
'order_item_type' => 'new',
}
],
'handling' => 'process'
}
};