Sweet Path::Class is Coming to Town
File and directory paths. They start off so simple, but then depending on which system the script runs on, they might use slashes or backslashes. And then there are spaces that come to mess everything up. And then there are those systems that use drive letters and volume names. And so on, and so forth.
You know what? Give yourself the gift of simplicity these holidays, and begin to use Path::Class.
Path::Class wraps all those file and directory operations in object-oriented goodness that will warm your DWIM-hungry little heart.
To begin with, creating the objects is pretty straight-forward:
And because the
file objects auto-stringify to their representing strings, it means that you can use them just like any regular path strings:
But as soon you discover the methods those objects have, you'll soooo not want to do that. Traveling up and down directory structures will now be a joy:
Cleaning up complicated paths? A wonder:
Utilities and shortcuts to create tempfiles, iterate through the directory entries or traverse the directory structure? All there:
Regular file operations are likewise simplified via nifty methods:
Trust me, once you begin using them, there'll be no going back. In fact, you'll probably wish they were also available as Moose types to use them everywhere natively.
And then you'll discover MooseX::Types::Path::Class, and the Christmas bells will be forevermore ringing.