Your SlideShare is downloading. ×
0
The Essential Perl Hackers Toolkit     Stephen R. Scaffidi    stephen@scaffidi.net       YAPC::NA 2012
Thanks for coming!
ContentsIntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and Typ...
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
This is a talk about the essentials
essential to...
getting my job done
getting my job done better
getting my job done faster
so I can go out and drink beer
so I can go out and drink beer spend time posting on reddit
so I can go out and drink beer spend time posting on reddit       watching youtube
so I can go out and drink beer spend time posting on reddit       watching youtubeDANCING WITH THE STARS
the editor of the previous three slides has                been sacked
I <3 Task::Kensho
This talk != Task::Kensho
But it is essential
So look it up:Task::Kensho
my @essentials
Modules and tools I depend on
make my job easier
make my code better
easier to write
easier to read
easier to maintain
fewer bugs
because...
this is the code I dont write
Im not that good.
Neither are you*
Neither are you**with several exceptions, half of them probablyleaving this room right now...
Previous iterations of this talk...
touchy-feely
waxed poetic about community
gushed about the CPAN
but...
theres simply no time
too many modules
too many modules  (on the dance floor)
I prefer Perl because of this           variety
No language is perfect
but...
Perl has the CPAN
And the CPAN gives us many, many ways to improve Perl
mst once said...
Perl is my VMCPAN is my language
so...
lets learn about some of the bestparts of this language we call the               CPAN
Allow me some hubris...for the next 40 minutes or so.
Bring out the modules!
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
strictwarnings
really?
experience tells me the answer is               yes.
English
Get English versions of Perls     “punctuation vars”
use English qw( -no_match_vars );
Examples$#@^ English$    $OUTPUT_RECORD_SEPARATOR$$    $PID$^O   $OSNAME$+    $LAST_PAREN_MATCH$!    $OS_ERROR$?    $CHILD...
perldoc perlvar
autodie
Does what it says on the tin...
# overrides various built-ins...use autodie;# Now, they all succeed or die!open my $foo, >, file.txt;chdir foo/bar;pipe my...
autodie is indispensable.Why write an “or die” clause after  every open() when you no      longer have to???
Data::Dumper
Better than print().
Data::Dump::Streamer
Better than Data::Dumper!
List::Util
List::UtilList::MoreUtils
List::UtilList::MoreUtils  Scalar::Util
For those go to Steve Lembarks talk on Util modules tomorrow             morning.
parent
Stop messing with @ISA
# sets up @ISA for youuse parent qw(Some::Base Other::Base);
Clear and declarative!
Try::Tiny
Stop messing with eval {} for    exception handling.
use Try::Tiny;try {    something_that_might_die();}catch {    handle_error($_); # note: not $@}finally {    clean_up();};
IO::All
Maybe not essential
But damn handy!
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
Not just modules
App::cpanminus
A light-weight cpan client that    understands local::lib
App::Ack
ack is better than grep
Devel::NYTProf
Hands-down, the best profiler for             Perl
Devel::Cover
Tells you how well your tests       cover your code
Speaking of tests...
prove
use it to run your tests
Lots of things under Test::
Test::More   and/orTest::Most
Many, many others...
Perl::Critic
Make sure your code confirms to   certain quality standards.
You do use coding standards,          right??
Moose         and/orMouse / Moo / Any::Moose
Stop writing your own OO layers
Stop doing it inconsistently
Stop messing up inheritance,  destructors, accessors and allthose little things that you have to   write over and over and...
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
File::Spec
my $path = join /, qw(foo bar baz)
What if it runs on Windows?           Or VMS?    Or early MacOS?          AcornOS?             QNX?
use File::Spec;my $correct_path =   File::Spec->catdir qw(foo bar baz);
use File::Spec::Functions qw(catdir);my $path = catdir qw(foo bar baz);
Declarative and correct
Lots of other functions, too:   ● canonpath   ● splitpath   ● catfile     ● splitdir   ● rootdir     ● catpath   ● updir  ...
Path::Class
use Path::Class qw(dir file);# create dir and file objects...my $dir = dir(foo, bar);my $file = file(bob, file.txt);# Stri...
File::Find
Traversing directories in a   filesystem is tricky.  Youre not that good.
File::Find::Rules
If you dont like File::Find,File::Find::Rules has some very      nice functionality. Try it.
File::Touch
For when you need to touch afile. Simple, and works cross-           platform.
File::Basename
same as the systems basename   and dirname commands.
File::Slurp
Simple thing... but which is more           readable?
my $text =  do { local(@ARGV, $/) = "file.txt"; <> };                       ormy $text = read_file file.txt;
File::ReadBackwards
When you need it... you DONT   want to do it yourself!
File::Temp
Let this module handle temp filesand directories for you and stop          doing it wrong.
File::HomeDir
Dont try to find a users home   directory on your own.
File::Which
Why are you shelling out to         which?        STOP IT!
File::Copy
Dont shell out to the system. Dont write your own copy           routine. Please, PLEASE, just use       File::Copy.
File::LibMagic    and/orFile::MimeInfo
If you need to recognize a      common file type...STOP DOING IT YOURSELF!!!
If one doesnt work for you, try          the other.
File::Path
recursively create and remove          directories
File::stat
Can you remember this?my ($dev, $ino, $mode, $nlink, $uid,  $gid, $rdev, $size, $atime, $mtime,  $ctime, $blksize, $blocks...
Maybe this?my $dev     =   (stat   $file)[0];my $ino     =   (stat   $file)[1];my $mode    =   (stat   $file)[2];my $nlink...
Try this, instead...use File::stat;my $s = stat $file;$s->dev;$s->ino;$s->size;         Much nicer, no?
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
Tie::IxHash         orTie::StoredOrderHash
Building your own sucks
Try this:use Tie::StoredOrderHash qw(ordered);my $hash = ordered [  one => 1, two => 2, three => 3];while (my($k, $v) = ea...
Hash::Merge::Simple
Recursively merge hash      structures
use Hash::Merge::Simple qw(merge);my $a = {  a => 1, c => 3,  d => { i => 2 }, r => {}};my $b = {  b => 2, a => 100,  d =>...
Simple, declarative and        correct.
Params::Util
use Params::Util qw(_SCALAR _HASH _INSTANCE);sub foo {  my $object = _INSTANCE(shift, Foo) or die;  my $image = _SCALAR(sh...
Sure, its ugly...
But focused on correctly doing   something common and      (surprisingly) tricky
Params::Validate
The de-facto standard in  parameter validation.
Algorithm::Combinatorics
Dont do combinatorics on yourown. Your code will be wrong. It   will be slow. It will suck.
Set::CrossProduct            orSet::CartesianProduct::Lazy
Just here for shameless self-         promotion.
Data::Compare
Recursively and correctlycompare data structures.
Test::Deep::NoTest
More functionality than  Data::Compare.
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
DateTime
The most correct handling ofdates and times in Perl. Use it.
DateTime::Format::Strptime           and/orDateTime::Format::DateManip
Use these to transform varioustime formats from strings into      DateTime objects
Time::Piece
Make localtime() and gmtime()return objects...use Time::Piece;my $t = localtime;print "Time is $tn";print "Year is ", $t->...
Time::Local
Gives you inverse functions for    localtime() and gmtime()use Time::Local qw(timelocal timegm);my $localtime = timelocal(...
DateTime::Tiny   (and friends)
If DateTime is too “heavy” for        you, at least useDateTime::Tiny, or Date::Tiny         or Time::Tiny
Time::ParseDate
Parsing dates and times is a     PITA. Use a module...use Time::ParseDate qw(parsedate);$epoch_time =  parsedate("12/11/94...
Date::Extract
When you need to extract datesand times from arbitrary blocks of             text...
But it tries hard to avoid false-             positives
Date::Extract::Surprise
For when youre willing to besurprised at the dates found!
Simply works harder to find dates and times in text, at the cost of    possibly false-positives.
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
YAML::Any
use YAML::Any qw(Dump Load);$YAML::Indent = 3;my $yaml = Dump(@objects);my @objects = Load($yaml);
JSON
use JSON qw(to_json from_json);my $json = to_json($perl_scalar);my $perl_scalar = from_json($json);
Text::CSV
use Text::CSV;my $csv = Text::CSV->new({ binary => 1 });open my $fh, "<:encoding(utf8)", "test.csv";while ( my $row = $csv...
URI URI::SplitURI::Escape
Spreadsheet::Read
Parse and read in a bunch ofdifferent spreadsheet formats,        including Excel.
XML::Simple
For simply reading in and parsing some XML into a data structure.  For non-simple stuff, look at        Task::Kensho!
Check Task::Kensho for more      XML essentials.
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
Module::Runtime
safely and properly load  modules at run-time
IO::Interactive
Do you know how to properlytest for an interactive terminal?          DOUBTFUL
IPC::Run
The grand-daddy of running external commands and     controlling the IO
Capture::Tiny
Capture stdout and stderr of any             code
It Just Plain Works(tm)
Net::Server    orNet::Daemon
Writing daemons properly is hard
String::ShellQuote
(my $unsafe_string =   q{string youre passing to system})      =~ s/([/;()])/$1/g
Unsafe, incorrect, and ugly.
use String::ShellQuote qw(shell_quote);my $safe_string = shell_quote   q{something you might pass to system};
Much safer and more correct
IPC::System::Simple
Make using system() and outputcapturing (a-la backticks) safer
use IPC::System::Simple   qw(system systemx);# overrides system() built-in...# Succeed or die, avoid shell if @argssystem(...
use IPC::System::Simple   qw(capture capturex);# Use capture() instead of backticks: (also works in list context)# Succeed...
IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealin...
Dont take my word for it
Explore the CPAN for yourself
Create your own toolkit
Be consistent
be thoughtful
Share what you learn
Contribute and help this   language grow!
Thanks again.Im hercynium on IRC and         twitter.
The Essential Perl Hacker's Toolkit
Upcoming SlideShare
Loading in...5
×

The Essential Perl Hacker's Toolkit

4,642

Published on

A whirlwind tour of the modules that any perl hacker, from beginner to experienced, should use and why.

Handout: List of modules in the talk along with many more: https://sites.google.com/site/perlhercynium/TEPHT-List2.pdf?attredirects=0

Published in: Technology
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total Views
4,642
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
105
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "The Essential Perl Hacker's Toolkit"

  1. 1. The Essential Perl Hackers Toolkit Stephen R. Scaffidi stephen@scaffidi.net YAPC::NA 2012
  2. 2. Thanks for coming!
  3. 3. ContentsIntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  4. 4. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  5. 5. This is a talk about the essentials
  6. 6. essential to...
  7. 7. getting my job done
  8. 8. getting my job done better
  9. 9. getting my job done faster
  10. 10. so I can go out and drink beer
  11. 11. so I can go out and drink beer spend time posting on reddit
  12. 12. so I can go out and drink beer spend time posting on reddit watching youtube
  13. 13. so I can go out and drink beer spend time posting on reddit watching youtubeDANCING WITH THE STARS
  14. 14. the editor of the previous three slides has been sacked
  15. 15. I <3 Task::Kensho
  16. 16. This talk != Task::Kensho
  17. 17. But it is essential
  18. 18. So look it up:Task::Kensho
  19. 19. my @essentials
  20. 20. Modules and tools I depend on
  21. 21. make my job easier
  22. 22. make my code better
  23. 23. easier to write
  24. 24. easier to read
  25. 25. easier to maintain
  26. 26. fewer bugs
  27. 27. because...
  28. 28. this is the code I dont write
  29. 29. Im not that good.
  30. 30. Neither are you*
  31. 31. Neither are you**with several exceptions, half of them probablyleaving this room right now...
  32. 32. Previous iterations of this talk...
  33. 33. touchy-feely
  34. 34. waxed poetic about community
  35. 35. gushed about the CPAN
  36. 36. but...
  37. 37. theres simply no time
  38. 38. too many modules
  39. 39. too many modules (on the dance floor)
  40. 40. I prefer Perl because of this variety
  41. 41. No language is perfect
  42. 42. but...
  43. 43. Perl has the CPAN
  44. 44. And the CPAN gives us many, many ways to improve Perl
  45. 45. mst once said...
  46. 46. Perl is my VMCPAN is my language
  47. 47. so...
  48. 48. lets learn about some of the bestparts of this language we call the CPAN
  49. 49. Allow me some hubris...for the next 40 minutes or so.
  50. 50. Bring out the modules!
  51. 51. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  52. 52. strictwarnings
  53. 53. really?
  54. 54. experience tells me the answer is yes.
  55. 55. English
  56. 56. Get English versions of Perls “punctuation vars”
  57. 57. use English qw( -no_match_vars );
  58. 58. Examples$#@^ English$ $OUTPUT_RECORD_SEPARATOR$$ $PID$^O $OSNAME$+ $LAST_PAREN_MATCH$! $OS_ERROR$? $CHILD_ERROR
  59. 59. perldoc perlvar
  60. 60. autodie
  61. 61. Does what it says on the tin...
  62. 62. # overrides various built-ins...use autodie;# Now, they all succeed or die!open my $foo, >, file.txt;chdir foo/bar;pipe my($baz), my($buh);readline $foo;print “Do you ever check for print errors???”;
  63. 63. autodie is indispensable.Why write an “or die” clause after every open() when you no longer have to???
  64. 64. Data::Dumper
  65. 65. Better than print().
  66. 66. Data::Dump::Streamer
  67. 67. Better than Data::Dumper!
  68. 68. List::Util
  69. 69. List::UtilList::MoreUtils
  70. 70. List::UtilList::MoreUtils Scalar::Util
  71. 71. For those go to Steve Lembarks talk on Util modules tomorrow morning.
  72. 72. parent
  73. 73. Stop messing with @ISA
  74. 74. # sets up @ISA for youuse parent qw(Some::Base Other::Base);
  75. 75. Clear and declarative!
  76. 76. Try::Tiny
  77. 77. Stop messing with eval {} for exception handling.
  78. 78. use Try::Tiny;try { something_that_might_die();}catch { handle_error($_); # note: not $@}finally { clean_up();};
  79. 79. IO::All
  80. 80. Maybe not essential
  81. 81. But damn handy!
  82. 82. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  83. 83. Not just modules
  84. 84. App::cpanminus
  85. 85. A light-weight cpan client that understands local::lib
  86. 86. App::Ack
  87. 87. ack is better than grep
  88. 88. Devel::NYTProf
  89. 89. Hands-down, the best profiler for Perl
  90. 90. Devel::Cover
  91. 91. Tells you how well your tests cover your code
  92. 92. Speaking of tests...
  93. 93. prove
  94. 94. use it to run your tests
  95. 95. Lots of things under Test::
  96. 96. Test::More and/orTest::Most
  97. 97. Many, many others...
  98. 98. Perl::Critic
  99. 99. Make sure your code confirms to certain quality standards.
  100. 100. You do use coding standards, right??
  101. 101. Moose and/orMouse / Moo / Any::Moose
  102. 102. Stop writing your own OO layers
  103. 103. Stop doing it inconsistently
  104. 104. Stop messing up inheritance, destructors, accessors and allthose little things that you have to write over and over and over again...
  105. 105. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  106. 106. File::Spec
  107. 107. my $path = join /, qw(foo bar baz)
  108. 108. What if it runs on Windows? Or VMS? Or early MacOS? AcornOS? QNX?
  109. 109. use File::Spec;my $correct_path = File::Spec->catdir qw(foo bar baz);
  110. 110. use File::Spec::Functions qw(catdir);my $path = catdir qw(foo bar baz);
  111. 111. Declarative and correct
  112. 112. Lots of other functions, too: ● canonpath ● splitpath ● catfile ● splitdir ● rootdir ● catpath ● updir ● abs2rel ● devnull ● rel2abs ● tmpdir ● file_name_is_absolute ● curdir ● case_tolerant
  113. 113. Path::Class
  114. 114. use Path::Class qw(dir file);# create dir and file objects...my $dir = dir(foo, bar);my $file = file(bob, file.txt);# Stringifies with proper separator on# each supported platformprint "dir: $dirn";print "file: $filen";# methods do what you expect...my $subdir = $dir->subdir(baz);my $parent = $subdir->parent;my $dir2 = $file->dir;
  115. 115. File::Find
  116. 116. Traversing directories in a filesystem is tricky. Youre not that good.
  117. 117. File::Find::Rules
  118. 118. If you dont like File::Find,File::Find::Rules has some very nice functionality. Try it.
  119. 119. File::Touch
  120. 120. For when you need to touch afile. Simple, and works cross- platform.
  121. 121. File::Basename
  122. 122. same as the systems basename and dirname commands.
  123. 123. File::Slurp
  124. 124. Simple thing... but which is more readable?
  125. 125. my $text = do { local(@ARGV, $/) = "file.txt"; <> }; ormy $text = read_file file.txt;
  126. 126. File::ReadBackwards
  127. 127. When you need it... you DONT want to do it yourself!
  128. 128. File::Temp
  129. 129. Let this module handle temp filesand directories for you and stop doing it wrong.
  130. 130. File::HomeDir
  131. 131. Dont try to find a users home directory on your own.
  132. 132. File::Which
  133. 133. Why are you shelling out to which? STOP IT!
  134. 134. File::Copy
  135. 135. Dont shell out to the system. Dont write your own copy routine. Please, PLEASE, just use File::Copy.
  136. 136. File::LibMagic and/orFile::MimeInfo
  137. 137. If you need to recognize a common file type...STOP DOING IT YOURSELF!!!
  138. 138. If one doesnt work for you, try the other.
  139. 139. File::Path
  140. 140. recursively create and remove directories
  141. 141. File::stat
  142. 142. Can you remember this?my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $file;
  143. 143. Maybe this?my $dev = (stat $file)[0];my $ino = (stat $file)[1];my $mode = (stat $file)[2];my $nlink = (stat $file)[3];my $uid = (stat $file)[4];my $gid = (stat $file)[5];my $rdev = (stat $file)[6];my $size = (stat $file)[7];# etc...
  144. 144. Try this, instead...use File::stat;my $s = stat $file;$s->dev;$s->ino;$s->size; Much nicer, no?
  145. 145. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  146. 146. Tie::IxHash orTie::StoredOrderHash
  147. 147. Building your own sucks
  148. 148. Try this:use Tie::StoredOrderHash qw(ordered);my $hash = ordered [ one => 1, two => 2, three => 3];while (my($k, $v) = each %$hash) { print "$k: $v ";} # one: 1 two: 2 three: 3
  149. 149. Hash::Merge::Simple
  150. 150. Recursively merge hash structures
  151. 151. use Hash::Merge::Simple qw(merge);my $a = { a => 1, c => 3, d => { i => 2 }, r => {}};my $b = { b => 2, a => 100, d => { l => 4 }};my $c = merge $a, $b;# $c is now {# a => 100, b => 2, c => 3,# d => { i => 2, l => 4 }, r => {} }
  152. 152. Simple, declarative and correct.
  153. 153. Params::Util
  154. 154. use Params::Util qw(_SCALAR _HASH _INSTANCE);sub foo { my $object = _INSTANCE(shift, Foo) or die; my $image = _SCALAR(shift) or die; my $opts = _HASHLIKE(shift) || {};}
  155. 155. Sure, its ugly...
  156. 156. But focused on correctly doing something common and (surprisingly) tricky
  157. 157. Params::Validate
  158. 158. The de-facto standard in parameter validation.
  159. 159. Algorithm::Combinatorics
  160. 160. Dont do combinatorics on yourown. Your code will be wrong. It will be slow. It will suck.
  161. 161. Set::CrossProduct orSet::CartesianProduct::Lazy
  162. 162. Just here for shameless self- promotion.
  163. 163. Data::Compare
  164. 164. Recursively and correctlycompare data structures.
  165. 165. Test::Deep::NoTest
  166. 166. More functionality than Data::Compare.
  167. 167. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  168. 168. DateTime
  169. 169. The most correct handling ofdates and times in Perl. Use it.
  170. 170. DateTime::Format::Strptime and/orDateTime::Format::DateManip
  171. 171. Use these to transform varioustime formats from strings into DateTime objects
  172. 172. Time::Piece
  173. 173. Make localtime() and gmtime()return objects...use Time::Piece;my $t = localtime;print "Time is $tn";print "Year is ", $t->year, "n";
  174. 174. Time::Local
  175. 175. Gives you inverse functions for localtime() and gmtime()use Time::Local qw(timelocal timegm);my $localtime = timelocal( $sec, $min, $hour, $mday, $mon, $year);my $gmtime = timegm( $sec, $min, $hour, $mday, $mon, $year);
  176. 176. DateTime::Tiny (and friends)
  177. 177. If DateTime is too “heavy” for you, at least useDateTime::Tiny, or Date::Tiny or Time::Tiny
  178. 178. Time::ParseDate
  179. 179. Parsing dates and times is a PITA. Use a module...use Time::ParseDate qw(parsedate);$epoch_time = parsedate("12/11/94 2pm", %options)
  180. 180. Date::Extract
  181. 181. When you need to extract datesand times from arbitrary blocks of text...
  182. 182. But it tries hard to avoid false- positives
  183. 183. Date::Extract::Surprise
  184. 184. For when youre willing to besurprised at the dates found!
  185. 185. Simply works harder to find dates and times in text, at the cost of possibly false-positives.
  186. 186. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  187. 187. YAML::Any
  188. 188. use YAML::Any qw(Dump Load);$YAML::Indent = 3;my $yaml = Dump(@objects);my @objects = Load($yaml);
  189. 189. JSON
  190. 190. use JSON qw(to_json from_json);my $json = to_json($perl_scalar);my $perl_scalar = from_json($json);
  191. 191. Text::CSV
  192. 192. use Text::CSV;my $csv = Text::CSV->new({ binary => 1 });open my $fh, "<:encoding(utf8)", "test.csv";while ( my $row = $csv->getline( $fh ) ) { $row->[2] =~ m/pattern/ or next; push @rows, $row;}
  193. 193. URI URI::SplitURI::Escape
  194. 194. Spreadsheet::Read
  195. 195. Parse and read in a bunch ofdifferent spreadsheet formats, including Excel.
  196. 196. XML::Simple
  197. 197. For simply reading in and parsing some XML into a data structure. For non-simple stuff, look at Task::Kensho!
  198. 198. Check Task::Kensho for more XML essentials.
  199. 199. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  200. 200. Module::Runtime
  201. 201. safely and properly load modules at run-time
  202. 202. IO::Interactive
  203. 203. Do you know how to properlytest for an interactive terminal? DOUBTFUL
  204. 204. IPC::Run
  205. 205. The grand-daddy of running external commands and controlling the IO
  206. 206. Capture::Tiny
  207. 207. Capture stdout and stderr of any code
  208. 208. It Just Plain Works(tm)
  209. 209. Net::Server orNet::Daemon
  210. 210. Writing daemons properly is hard
  211. 211. String::ShellQuote
  212. 212. (my $unsafe_string = q{string youre passing to system}) =~ s/([/;()])/$1/g
  213. 213. Unsafe, incorrect, and ugly.
  214. 214. use String::ShellQuote qw(shell_quote);my $safe_string = shell_quote q{something you might pass to system};
  215. 215. Much safer and more correct
  216. 216. IPC::System::Simple
  217. 217. Make using system() and outputcapturing (a-la backticks) safer
  218. 218. use IPC::System::Simple qw(system systemx);# overrides system() built-in...# Succeed or die, avoid shell if @argssystem("some_command",@args); # NEVER invokes the shellsystemx("some_command",@args);
  219. 219. use IPC::System::Simple qw(capture capturex);# Use capture() instead of backticks: (also works in list context)# Succeeds or dies,# avoids shell if @argsmy $output = capture("some_command",@args); # NEVER invokes the shellMy $output = capturex("some_command",@args);
  220. 220. IntroductionThe Little ThingsSlightly Bigger ThingsHandling Files and FilesystemsWrangling Data Structures and TypesDealing with Dates and TimesReading and Writing File FormatsPotpourriConclusion
  221. 221. Dont take my word for it
  222. 222. Explore the CPAN for yourself
  223. 223. Create your own toolkit
  224. 224. Be consistent
  225. 225. be thoughtful
  226. 226. Share what you learn
  227. 227. Contribute and help this language grow!
  228. 228. Thanks again.Im hercynium on IRC and twitter.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×