Mais conteúdo relacionado
Semelhante a Path::Tiny (20)
Path::Tiny
- 4. _Ÿv_tXcaŠe
my $file = path("/home/waniji/memo.txt");
# ファイル名のみ表示
say $file->basename;
# ファイルに書き込み
my $fh = $file->openw;
$fh->print("chiba.pm")
# ファイルの内容をすべて読み込み
my $data = $file->slurp;
# ファイルを削除
$file->remove;
# 一時ファイルを作成
my $temp = Path::Tiny->tempfile;
- 5. Æ¢ë®ÇéAzÔ £êDžª¥òÇ
my $file = path(/home/waniji/);
my $iterator = $file-iterator( { recurse = 1 } );
while( my $object = $iterator-() ) {
$count++ if $object-is_file;
}
- 8. ØòÀÝ–®(Ô £êw„YŸsg)
my $path = /home/waniji/hoge.txt;
cmpthese( 10000, {
'Path::Tiny' = sub {
my $file = path($path);
$file-openw-print(aaa);
$file-remove;
},
'Path::Class' = sub {
my $file = file($path);
$file-openw-print(aaa);
$file-remove;
},
});
Rate Path::Class Path::Tiny
Path::Class 1862/s -- -29%
Path::Tiny 2632/s 41% --
- 9. ØòÀÝ–®(Æ¢ë®ÇéAzÔ £êžª¥òÇ)
my $path = /home/waniji/temp;
cmpthese( 100, {
'Path::Tiny' = sub {
my $dir = path($path);
my $iterator = $dir-iterator( { recurse = 1 } );
my $count;
while( my $object = $iterator-() ) {
$count++ if $object-is_file;
}
},
'Path::Class' = sub {
my $dir = dir($path);
my $count;
$dir-recurse( callback = sub {
my $object = shift;
$count++ if -f $object;
});
},
}); Rate Path::Class Path::Tiny
Path::Class 10.7/s -- -67%
Path::Tiny 32.1/s 200% --