my @database = read_from_db(); while (1){ my $id = prompt "Enter the product ID: ", -escape; return write_to_db($database_type, @database) if $id eq "\e"; my $comments = prompt "Enter any comments about this product: ", -escape; return write_to_db($database_type, @database) if $comments eq "\e"; print "Confirm the following data:\n"; print "Product ID: $id\n"; print "Comments: $comments\n\n"; my $yn = prompt "Is this information correct? y/n: ", -yn; #no escape here since this info will get lost if we escape redo if ! $yn; push(@database, [$id, $comments]); $yn = prompt "Add another entry? y\n: ", -yn, -escape; last if !yn || $yn eq "\e"; } write_to_db($database_type, @database);