2020年4月21日火曜日

開発環境

初めてのPerl 第7版 (Randal L. Schwartz(著)brian d foy(著)Tom Phoenix(著)近藤 嘉雪(翻訳)嶋田 健志(翻訳)、オライリージャパン)の2章(スカラーデータ)、2.12(練習問題)5の解答を求めてみる。

コード

#!/usr/bin/env perl
use strict;
use warnings;
use v5.28;

say '5.';

print '文字列を入力: ';
my $s = <STDIN>;

print '数値を入力(繰り返す回数): ';
chomp(my $n = <STDIN>);

print $s x $n;

入出力結果(Zsh、PowerShell、Terminal)

% ./sample5.pl 
5.
文字列を入力: fred
数値を入力(繰り返す回数): 3
fred
fred
fred
%% ./sample5.pl
5.
文字列を入力: 
数値を入力(繰り返す回数): 3



%% ./sample5.pl
5.
文字列を入力: fred
数値を入力(繰り返す回数): 0
%% 

0 コメント:

コメントを投稿