coming back to Perl, file slurping with IO:All

Having spent many years working jobs that involved no Perl programming I felt I was getting rusty so I re-read "Perl Best Practices". It is 2011 now, I should checkout what new things have developed in the Perl world. I was pointed towards Task::Kensho .

Task::Kensho is a glimpse at an enlightened Perl. After reading that I decide to see what it could do for me right now.

I was writing a script and I need to slurp a few files. Under Task::Kensho::Hackery I see "IO:All combines all of the best Perl IO modules into a single nifty object oriented interface to greatly simplify your everyday Perl IO idioms." With boasting like that I expected a fast and simple solution. I was not disappointed.

use warnings; use strict; use IO::All qw(slurp);

my @rcfile = io('rcfile')->slurp;
my @delta_data = io('delta_data')->slurp;
my @log_data = io('log-488')->slurp;

That little work and I was on my way to getting things done. I look forward to seeing what else Task::Kensho can help me with.


IO::All is cool, but for everyday use I find File::Slurp adequate.

Or Perl6::Slurp, although it has less features...

And if you want a good book, check out Modern Perl. It was published in 2010 and contains much goodness.

Leave a comment

About Kimmel

user-pic I like writing Perl code and since most of it is open source I might as well talk about it too. @KirkKimmel on twitter