Snippets

sironekotoro Perl入学式 2018 第2回 練習問題 question_word.pl

Created by sironekotoro
#!/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";
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.