in reply to matching a regular expression
use strict; use warnings; my $rxInput = qr {(?x) ^ ( h(?:s(?:b(?:n)?)?)? | a(?:d(?:m(?:i(?:n)?)?)?)? ) $ }; print "What network? "; my $resp; chomp($resp = <STDIN>); print "Invalid response\n" unless $resp =~ $rxInput; # Do something here with $1 ...
I hope this is of use.
Cheers,
JohnGG
Update: Noticed and corrected cut-and-paste error where I initialised a prompt string rather than printing it.
|
|---|