in reply to matching a regular expression
... is that what you're asking for?
good luckmy $valid = 0; my $state; my $firstAttempt = 1; while(!$valid){ if($firstAttempt) { $state = promptUser("What network to listen for SNMP t +raps [hsbn or admin]? ", "admin"); $firstAttempt = 0; } else { $state = promptUser("ERROR:$state Invalid Re-enter the + network", "admin"); } if($state =~ /^hsbn|admin$/) { $valid = 1; } } if ($state =~ /^hsbn$/i) { //some action for hsbn } elsif ( $state =~ /^hsb$/ ) { //some action for hsb } elsif ( $state =~ /^hs$/) { //some action for hs } elsif ( $state =~ /^h$/ ) { //some action for h }
|
|---|