開発環境
- macOS Catalina - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Strawberry Perl (WindowsのPerlの言語処理系)
- Visual Studio Code (Text Editor)
- Perl 5.28 (プログラミング言語)
初めてのPerl 第7版 (Randal L. Schwartz(著)、brian d foy(著)、Tom Phoenix(著)、近藤 嘉雪(翻訳)、嶋田 健志(翻訳)、オライリージャパン)の15章(プロセス管理)、15.9(練習問題)3の解答を求めてみる。
コード
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use v5.18;
use Encode::Locale;
binmode STDIN, ':encoding(console_in)';
binmode STDOUT, ':encoding(console_out)';
binmode STDERR, ':encoding(console_out)';
say '3.';
my $date = `date`;
if (index($date, '土') or index($date, '日曜')) {
say '遊びに行く';
} else {
say '仕事に行く';
}
my $date1 = localtime();
unless (index $date1, 'S') {
say 'go play';
} else {
say 'go to work';
}
入出力結果(Zsh、cmd.exe(コマンドプロンプト)、Terminal)
% ./sample3.pl 3. 遊びに行く go play %
0 コメント:
コメントを投稿