2020年5月7日木曜日

開発環境

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

コード

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

say '5.';

while (<>) {
    chomp;
    if (/(\S)\1/) {
        say $_;
    }
}

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

% cat sample.txt 
Fred
frederick
Alfred
fred flintstone
Mr. Slate
Fred
Mississippi
Bamm-Bamm
llama
wilma
fred
FRED
wilma fred
fred wilma
wilmafred
WilmaFred
% ./sample5.pl sample.txt 
5.
Mississippi
Bamm-Bamm
llama
%

0 コメント:

コメントを投稿