Snippets

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

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

# Perl入学式 2018 第2回 練習問題
# calc.pl

print "INPUT 1st NUMBER > ";
my $first_num = <STDIN>;
chomp $first_num;

print "INPUT 2nd NUMBER > ";
my $second_num = <STDIN>;
chomp $second_num;


# 書き方は色々ある・・・けど、わかりやすい書き方を意識する
# 文字列と計算結果(数字)を分けるとわかりやすいのではないか
print "$first_num + $second_num = " . ( $first_num + $second_num ) . "\n";
print "$first_num - $second_num = " . ( $first_num - $second_num ) . "\n";
print "$first_num * $second_num = " . ( $first_num * $second_num ) . "\n";
print "$first_num / $second_num = " . ( $first_num / $second_num ) . "\n";

Comments (0)