Greetings,

I am attempting to limit entries a user could make when inputting names into
one of my scripts.  I prompt the user to enter one or more names.  One name
is easy to isolate but when there are more I want to support commas.  At the
same time I don't want to accept anything other than names and commas.  I
want to force the user to either enter names correctly or exit.  For that
matter it would be really cool if I could test the names against
/etc/passwd.  But beggars can't be choosers I will tackle the array piece
later. 

What the user sees:

Please enter user name(s):
If more than one separate using commas
example (single name): evan
example (multi name): debbie, clint, henry



So far what broken pieces I have...

#!/usr/bin/perl


while($ans !~ /^[a-z]+$/ || $ans !~ /^[a-z]+\,?[a-z]*$/) {
  errmesg ();
  $ans = <STDIN>;

};

sub errmesg {
  print "\nType user name(s) and press enter:\n";
  print "note: if more than one separate using commas\n";
  print "example (single name): evan\n";
  print "example (multi name): debbie, clint, henry\n";
}

Reply via email to