揮発性のメモ2

http://d.hatena.ne.jp/iww/

ファイルの内容を全て文字列に読み込む

プロセス生成のコストとか気になったらちゃんと書き直す。気にならなければこのまま。

my $text = `cat a.txt`;
my $text = do { local $/=undef; open(my $fh,"a.txt"); <$fh> };
my $text;
open(my $fh,"a.txt");
while(<$fh>){ $text.=$_ }
open(my $fh,"a.txt");
my $text = join "", <$fh>;
my $text = do{ open(my $fh,"a.txt"); join "",<$fh> };
# apt-get install libfile-slurp-perl

use File::Slurp;
my $text = read_file("a.txt");