[perl] [select]

perl の 出力のデフォルトファイルハンドルを変更するというselect関数を使ってみた。

      5
      6 open(FILE, ">$file") or die $!;
      7
      8 print "hoge\n";
      9
     10 select(FILE);
     11
     12 print "hoge\n";
     13

んな感じに切り替えてくれる。

[hoge] perl select.pl aaa.txt
hoge
[hoge] cat aaa.txt
hoge

http://flex.ee.uec.ac.jp/texi/perl/perl_68.html
http://search.cpan.org/~gbarr/IO-1.2301/IO/Select.pm