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; } } }
In reply to really easy ? but want nice succinct code by bcole23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |