読書環境
- Kindle(白黒)
- iPad Pro 10.5 + Kindle(カラー)
- 紙
開発環境
- 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(著)、近藤 嘉雪(翻訳)、嶋田 健志(翻訳)、オライリージャパン)の10章(さまざまな制御構造)、10.5(elsif節)のコードに誤植があったみたいなのでオライリー・ジャパンさんに報告してみた。
初めてのPerl 第7版 (2018年1月24日 初版第1刷発行)について。
p.183の10.5(elsif節)のコードについて、正規表現の部分はoverline(?)ではなくtilde(「~」)はないかと。(印刷上の問題?)
一応、tildeに書き換えて実行してみた。
コード
#!/usr/bin/env perl
for $dino (undef, 12, 1.2, '', 'perl') {
print "\$dino = '$dino'\n";
if (!defined $dino) {
print "The value is undef.\n";
} elsif ($dino =~ /^-?\d+\.?$/) {
print "The value is an integer.\n";
} elsif ($dino =~ /^-?\d+\.?$/) {
print "The value is a _simple_ floating-point number.\n";
} elsif ($dino eq '') {
print "The value is the empty string.\n";
} else {
print "The value is the string '$dino'.\n";
}
}
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal)
$ ./sample.pl $dino = '' The value is undef. $dino = '12' The value is an integer. $dino = '1.2' The value is the string '1.2'. $dino = '' The value is the empty string. $dino = 'perl' The value is the string 'perl'. $
0 コメント:
コメントを投稿