in reply to
On goto
Trivially eliminating the goto, I'd go with:
{
ask('databasetype','Database type?','mysql');
my $found; # aside: I hate " = undef"
foreach $cur (@databases) {
if (getConf('databasetype') eq $cur) {
$found = 1;
last;
}
}
unless ($found) {
output "Sorry, invalid option\n\n";
redo;
}
}
Next, I hate the artificial
$found variable, so
I'd merely move that into a subroutine:
{
ask('databasetype','Database type?','mysql');
unless (is_databasetype_valid()) {
output "Sorry, invalid option\n\n";
redo;
}
}
sub is_databasetype_valid {
foreach my $cur (@databases) {
if (getConf('databasetype') eq $cur) {
return 1;
}
}
return 0;
}
That'd probably be enough, but that call to
getConf seems to be perhaps invariant in that loop, so I'd pull it out to call the subroutine only once during the scan of
@databases.
But hopefully, you get the idea now.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.