SlideShare a Scribd company logo
PATH::TINY 
Chiba.pm #5 / @waniji
ß…Ãu 
@waniji 
´–Ï´£È§ò·Ê¡ 
VimsPerl„PrŠe
PATH::TINYt{ 
Ô £êìfá·ä–ê 
Path::ClasszTinyh 
File::Spec, File::Copy, File::Temp, File::Path, File::statvuž 
žoríR{vX|_zá·ä–ê1pslPkPca 
Še 
David Golden·XAuthor
_Ÿ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;
Æ¢ë®ÇéAzÔ £êDžª¥òÇ 
my $file = path(/home/waniji/); 
my $iterator = $file-iterator( { recurse = 1 } ); 
while( my $object = $iterator-() ) { 
$count++ if $object-is_file; 
}
Po}P/^•˜— 
# /home/waniji/chibapm/memo.txt に aaa という文字列を書き込み 
my $file = path(/home/waniji/memo.txt); 
$file-parent-child(chibapm, memo.txt)-touchpath-openw-print(aaa);
PATH::CLASStz‡¶ 
ŸaP 
íP 
1Ô £ê 
UTF-8Jzà¼ÂÈXJa˜rP— 
Unix or Windows z‹”f;Ë
ØòÀÝ–®(Ô £ê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% --
ØòÀÝ–®(Æ¢ë®Çé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% --
UTF-8zÔ £êžopencr‹— 
# Path::Class 
my $fh = $file-open(':encoding(UTF-8)') or die can't open $file: $!; 
# Path::Tiny 
my $fh = $file-openr_utf8;
PATH::TINYsÎÝok_t
ì–ªêW•NFSwÔ £êž¤” 
my $file = path(/home/waniji/memo.txt); 
$file-move(/nfs/memo.txt); 
ŒŒ 
¾{±¿z¶{½ 
‹Y^Y^Y^Y^Y‹
Path::Tinyzmove{ÆósrenamežžJcrP—k| £v 
—Ô £ê¶¸Åßw¤”e—_t{cavP} 
sub move { 
my ( $self, $dst ) = @_; 
return rename( $self-[PATH], $dst ) 
|| $self-_throw( 'rename', $self-[PATH] . ' - '$dst' ); 
}
PCŽ 
use File::Copy 'move'; 
move $file, /nfs/memo.txt;
Št 
6q

More Related Content

PDF
PuppetCamp SEA 1 - Version Control with Puppet
Walter Heck
 
ODT
Huong dan cai dat hadoop
Quỳnh Phan
 
TXT
Cpsh sh
Ben Pope
 
PPTX
Raspberry pi Part 4
Techvilla
 
PDF
Perl Fitxers i Directoris
frankiejol
 
XLS
Up.Php
wsoom
 
PPTX
R- create a table from a list of files.... before webmining
Gabriela Plantie
 
PPT
17 sessions
Abhijit Gaikwad
 
PuppetCamp SEA 1 - Version Control with Puppet
Walter Heck
 
Huong dan cai dat hadoop
Quỳnh Phan
 
Cpsh sh
Ben Pope
 
Raspberry pi Part 4
Techvilla
 
Perl Fitxers i Directoris
frankiejol
 
Up.Php
wsoom
 
R- create a table from a list of files.... before webmining
Gabriela Plantie
 
17 sessions
Abhijit Gaikwad
 

What's hot (20)

PDF
File system
Gayane Aslanyan
 
PDF
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Puppet
 
PDF
Plone Conference 2008 Lightning Talk Static Zope Rpx
Paris, France
 
PDF
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet
 
PDF
Not Really PHP by the book
Ryan Kilfedder
 
ODP
Perl5i
Marcos Rebelo
 
PPTX
Ch3(working with file)
Chhom Karath
 
PDF
TDC São Paulo 2016 - Become a jedi with php streams
Matheus Marabesi
 
TXT
Logrotate sh
Ben Pope
 
KEY
Introduction to DBIx::Lite - Kyoto.pm tech talk #2
Hiroshi Shibamura
 
PDF
scdevsumit 2016 - Become a jedi with php streams
Matheus Marabesi
 
PDF
Laporan setting dns
Septian Adi
 
DOC
Important info
luvitadev
 
PPTX
PHP Basics and Demo HackU
Anshu Prateek
 
PPT
Php i basic chapter 4
Muhamad Al Imran
 
ODP
PHP pod mikroskopom
Saša Stamenković
 
PDF
News of the Symfony2 World
Fabien Potencier
 
PPTX
Linux Shell Scripts and Shell Commands✌️
Nazmul Hyder
 
TXT
Threading
b290572
 
PDF
PerlでWeb API入門
Yusuke Wada
 
File system
Gayane Aslanyan
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Puppet
 
Plone Conference 2008 Lightning Talk Static Zope Rpx
Paris, France
 
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet
 
Not Really PHP by the book
Ryan Kilfedder
 
Ch3(working with file)
Chhom Karath
 
TDC São Paulo 2016 - Become a jedi with php streams
Matheus Marabesi
 
Logrotate sh
Ben Pope
 
Introduction to DBIx::Lite - Kyoto.pm tech talk #2
Hiroshi Shibamura
 
scdevsumit 2016 - Become a jedi with php streams
Matheus Marabesi
 
Laporan setting dns
Septian Adi
 
Important info
luvitadev
 
PHP Basics and Demo HackU
Anshu Prateek
 
Php i basic chapter 4
Muhamad Al Imran
 
PHP pod mikroskopom
Saša Stamenković
 
News of the Symfony2 World
Fabien Potencier
 
Linux Shell Scripts and Shell Commands✌️
Nazmul Hyder
 
Threading
b290572
 
PerlでWeb API入門
Yusuke Wada
 
Ad

Recently uploaded (20)

PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
The Future of Artificial Intelligence (AI)
Mukul
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Ad

Path::Tiny