perl いろいろな正規表現1

#入力された英文を単語ごとに区切り、「単語:区切られた単語」のように表示するスクリプト
$ward = <STDIN>;
chomp($ward);

print "単語:$&\n" while($ward =~ /\w+/g);

#実行結果
#There's more than one way to do it

# There's more than one way to do it
# 単語:There
# 単語:s
# 単語:more
# 単語:than
# 単語:one
# 単語:way
# 単語:to
# 単語:do
# 単語:it

初めてのPerl 第6版

初めてのPerl 第6版