Created by sironekotoro 2018-05-27 View revision File sum.pl Added Side-by-side diff More Ignore whitespace Hide word diff +#!/usr/bin/env perl +use strict; +use warnings; + +# Perl入学式 2018 第2回 復習問題 +# https://github.com/perl-entrance-org/workshop-2018/blob/master/2nd/practice.md +# 復習問題(sum.pl) + +# 1から100までの値を配列に格納し, その配列の全ての数値を足した結果を出力するsum.plを作成しよう + +my @number = ( 1 .. 100 ); +my $sum = 0; +for my $num (@number) { + $sum += $num; +} +print $sum; # 5050