まだ perl に慣れていないので、データベース タスクを実行するために MySQL と一緒に使用する方法を学ぼうとしています。ユーザーにメニューを提供する perl スクリプトの開始点から、入力を求めるよりもはるかに離れていないことを願っています。ユーザー入力を以前に指定したテーブルにロードする番号 1 から始めました。質問は、その選択が完了したときに menu print ステートメントに戻る効率的な方法は何ですか? それで、彼らはアカウントなどを作成し続けることができましたか?
print "User Menu(please select 1-5):\n 1)Create a new account\n 2)List all the times that an account has logged in\n 3)Log in/out of account\n 4)Drop and re-create the necessary database tables\n 5)Quit\n";
$userInput = <>;
if($userInput == 1){
print "Please enter a user name: ";
$user_name = <>;
print "Please enter a password: ";
$password = <>;
$dbh->do("INSERT INTO user_accounts VALUES ('$user_name','$password')");
#Trying to loop back to the menu.....
#}elsif($userInput == 2){
#test:print "I am number 3";
#}elsif($userInput == 3){
#test:print "I am number 3";
#}elsif($userInput == 4){
#$dbh->do('DROP TABLE IF EXISTS user_accounts');
#test print "I am number 4";
}else{
exit;
}