in reply to matching a regular expression

This regular expression would do what you want for the choices of "hsbn" or "admin" and capture what the user entered in $1 for later processing.

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.