開発環境
- macOS Mojave - 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(著)、近藤 嘉雪(翻訳)、嶋田 健志(翻訳)、オライリージャパン)の5章(入力と出力)、5.13(練習問題)1の解答を求めてみる。
コード
#!/usr/bin/env perl use strict; use warnings; use utf8; use autodie; use v5.18; # Wide character in print at ... line ...が出力されないようにに指定 # 付録C(Unicode入門)、C.4(ファンシーな文字)、C.4.2(さらにファンシーな文字)より # WindowsとmacOSのどちらでも標準入力、標準出力、標準エラーについてちゃんと動くように設定 use Encode::Locale; binmode STDIN, ':encoding(console_in)'; binmode STDOUT, ':encoding(console_out)'; binmode STDERR, ':encoding(console_out)'; say '1.'; print reverse <<>>;
入出力結果(cmd(コマンドプロンプト)、Terminal)
C:\Users\...>type fred barney betty fred1 fred2 fred3 fred4 fred5 barney1 barney2 betty1 betty2 betty3 betty4 betty5 betty6 betty7 betty8 betty9 betty10 C:\Users\...>perl tac.pl fred barney betty 1. betty10 betty9 betty8 betty7 betty6 betty5 betty4 betty3 betty2 betty1 barney2 barney1 fred5 fred4 fred3 fred2 fred1 C:\Users\...>perl -e 'print reverse <<>>' fred barney betty betty10 betty9 betty8 betty7 betty6 betty5 betty4 betty3 betty2 betty1 barney2 barney1 fred5 fred4 fred3 fred2 fred1 C:\Users\...>
0 コメント:
コメントを投稿