use strict; use warnings; use diagnostics; my ($input, $value) my %vlan = ( "vlan1" => "", "vlan2" => "", "vlan3" => "", "vlan4" => "", ); sub verification { print "Entering the subroutine\n"; #added for debugging purposes print "$value"; #added for debugging purposes if ($value =~ m{(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\. (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\. (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\. (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/ (2[0-4]?$)}x) { %vlan{$value}=$input; } else { print "\t\tInvlaid response. Please try again.\n"; #enter return } print "Exiting the subroutine.\n"; #added for debugging purposes } ---lines omitted--- print "Enter IP address in x.x.x.x/x format\n"; foreach $_(keys %vlan) { print "\t$_: "; chomp ($input = ); $input = $value; #call subroutine to check user input verification($value) }