リストのつくり方(ひねくれ編)
Perl Cookbookより
my @list = (<< "EOD" =~ /^\s*(.+)/gm); I sit beside the fire and think of all that I have seen, of meadow-flowers and butterflies and summers that have been; EOD foreach (@list){ print $_ . "\n"; }
# 出力結果 I sit beside the fire and think of all that I have seen, of meadow-flowers and butterflies and summers that have been;
こゆこと.正規表現マッチのgオプションはリストを生成する,というしかけ.
しかし,
dan kogai氏がインタビューで「Perlはフリーダムすぐる」と言った理由(そう言ったのはMatz氏らしいけれど)ここにあり.という感じ.
Perl Cookbook: Solutions & Examples for Perl Programmers
- 作者: Tom Christiansen,Nathan Torkington
- 出版社/メーカー: O'Reilly Media
- 発売日: 2003/08/31
- メディア: ペーパーバック
- クリック: 5回
- この商品を含むブログ (4件) を見る