bcole23 has asked for the wisdom of the Perl Monks concerning the following question:
All I want is to make sure the entry is in the array and allow a nice way to try again or exit. I know there are really nice easy ways in probably one line of code to do this...... Your help is appreciated.my $DB; my @DB = qw(DB1 DB2); &select_db(); if (!$DB) {&select_db();} if ($DB eq 'Q') {die;} sub select_db { print "Select a database: "; $DB = <STDIN>; for (@DB) { if ($DB =~ /$_/i) { return $DB; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: really easy ? but want nice succinct code
by derby (Abbot) on Aug 16, 2002 at 20:50 UTC | |
|
Re: really easy ? but want nice succinct code
by DamnDirtyApe (Curate) on Aug 16, 2002 at 20:58 UTC | |
|
(jeffa) Re: really easy ? but want nice succinct code
by jeffa (Bishop) on Aug 16, 2002 at 21:06 UTC | |
|
Re: really easy ? but want nice succinct code
by tommyw (Hermit) on Aug 16, 2002 at 21:00 UTC | |
|
Re: really easy ? but want nice succinct code
by BrowserUk (Patriarch) on Aug 16, 2002 at 23:38 UTC | |
by bcole23 (Scribe) on Aug 19, 2002 at 20:42 UTC |