1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/usr/bin/env perl use strict; use warnings; my $answer = 'perl'; # 好きな文字を入力しておく # Perl入学式 2018 第2回 練習問題 # question_word.pl # 簡単な文字当てゲーム question_word.plを作成しよう # 端末から, 標準入力で文字列を一つ入力し, その文字列が$answerと一致したらOK, 外れたらNGと表示します print "INPUT hidden word > "; my $input = <STDIN>; chomp $input; if ($answer eq $input){ print "OK\n"; }else{ print "NG\n"; }
You can clone a snippet to your computer for local editing. Learn more.