Perhaps something like this? (Completely untested)
my @bonds = qw(bond2 bond3 bond4 bond6 bond7 bond8); my %ipaddress_namei; while (my @bonds_with_invalid_ip = grep { not exists $ipaddress_namei{ +$_}, $_ }, @bonds) { for my $bond (@bonds_with_invalid_ip) { printf "Enter IP address of %s\n", ucfirst($bond); my $bond_in = <STDIN>; chomp($bond_in); if (is_ipv4($bond_in)) { $ipaddress_namei{$bond} = {$bond_in}; } } }
Update, a little simpler, using a FIFO:
my @bonds = qw(bond2 bond3 bond4 bond6 bond7 bond8); my %ipaddress_namei; # Use @bonds as a FIFO while (my $bond = shift @bonds) { printf "Enter IP address of %s\n", ucfirst($bond); my $bond_in = <STDIN>; chomp($bond_in); if (is_ipv4($bond_in)) { $ipaddress_namei{$bond} = {$bond_in}; } else { # try again next time around push @bonds, $bond; } }
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re: Ask user to enter IP address repitatively for entities like Netmask, Gateway, DNS, bonds etc till correct address entered
by QM
in thread Ask user to enter IP address repitatively for entities like Netmask, Gateway, DNS, bonds etc till correct address entered
by rahulruns
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |