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.
In reply to Re: matching a regular expression
by johngg
in thread matching a regular expression
by s_gaurav1091
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |