Snippets

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

Created by sironekotoro
#!/usr/bin/env perl
use strict;
use warnings;

# Perl入学式 2018 第2回 練習問題
# https://github.com/perl-entrance-org/workshop-2018/blob/master/2nd/slide.md
# 練習問題(for.pl)

# 配列@arrayに好きな数値や文字列を設定し、for文で出力してください。
# <STDIN>を用いて配列@array2に好きな数値や文字列を入力し、for文で出力してください。

print "----------\n";
print "Question 1\n";
print "----------\n";
my @array = ( 'Exercise', 'Meditation', 'Vegetable 350g' );
for my $element (@array) {
    print "$element\n"
}

print "----------\n";
print "Question 2\n";
print "----------\n";
print "INPUT your like word > ";
my $word = <STDIN>;
chomp $word;
print "INPUT your like number > ";
my $number = <STDIN>;
chomp $number;
print "INPUT your like programming language > ";
my $lang = <STDIN>;
chomp $lang;

my @array2 = ($word , $number , $lang);
for my $element(@array2){
    print "$element\n";
}

Comments (0)