Hello!
I have the following data(sanitized) :
print Dumper \%vars
$VAR1 = {
'group1' => '10.100.27.52',
'group2' => '10.100.27.53',
'group3' => '10.100.27.54',
'group4' => '10.100.27.55',
'group5' => '10.100.27.56',
'group6' => '10.100.27.57',
};
print Dumper \@tables
$VAR1 = [
{
'tablename' => '<table1>',
'ips' => [
'"10.100.29.0/24"'
]
},
{
'ips' => [
'$group1',
'$group2',
'$group3'
],
'tablename' => '<table2>'
},
{
'tablename' => '<table3>',
'ips' => [
'$group4',
'$group5'
'$group6'
]
}
];
How can I have the following output?
<table1>,"10.100.29.0/24"
<table2>,10.100.27.52
<table2>,10.100.27.53
<table2>,10.100.27.54
<table3>,10.100.27.55
<table3>,10.100.27.56
<table3>,10.100.27.57
Here is what I've tried:
for my $table (@tables) {
foreach my $entry ($table->{ips}) {
print $table->{tablename};
print $vars{$entry};
}
}
My problem is that I don't understand what I should use to loop over
'ips' and what to put inside $vars{}. Is my data structure appropriate
to my needs?
Let me know If you need more information, if you need the full code, etc
Thanks in advance
--
Vincent Lequertier
skysymbol.github.io
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/