in reply to Ask user to enter IP address repitatively for entities like Netmask, Gateway, DNS, bonds etc till correct address entered

Hi,

Have your code inside the while(1) like below,

my %ipaddress_namei = (); while(1) { print "Enter IP address of Bond2\n"; my $bond2 = <STDIN>; chomp($bond2); if(&validate_ip($bond2)) { $ipaddress_namei{bond2} = {$bond2}; last; } } sub validate_ip { #return 0; return 1; }

It will ask you to enter the IP address, and calls a function to validate the IP address, in function validate_ip do your validation part and return 1 for true, 0 for false, based on that the while will continue to get the input. This code will get the valid IP only once.


All is well
  • Comment on Re: Ask user to enter IP address repitatively for entities like Netmask, Gateway, DNS, bonds etc till correct address entered
  • Select or Download Code