Hello, erm, "Evan N Mr Niso/Lockheed Martin Kehayias" This should do what you want:
my @names; do { errmesg() if @names; my $ans = <STDIN>; @names = split /\s*,\s*/, $ans; } while (grep {/[^a-zA-Z]/} @names); which splits on commas with any amount of preceding and trailing whitespace. Names have to be alphabetic. HTH, Rob "Evan N Mr Niso/Lockheed Martin Kehayias" <[EMAIL PROTECTED]> wrote in message 90AFE0B84E52EE46A8CD1DB0789C0A860ED043@DADC144">news:90AFE0B84E52EE46A8CD1DB0789C0A860ED043@DADC144... > 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"; > } > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]