Last Updated: February 25, 2016
·
1.308K
· creaktive

Zip your Perl one-liners

Paraphrasing Larry Wall, the trouble with the Perl one-liners is that they doesn't necessarily fit 80 columns.
There are so many flags to pass to perl, like STDIO encoding, include paths, module imports... And parsing multiple structured files through one-liner can be painful.

Thankfully, there is App::p - Steroids for your perl one-liners.
It does few things, but does it really well. It automates lazy dependency loading (no need to type -M anymore!) and adds several convenient shortcuts for commonly used functions.

So, brace yourselves, let's use Perl as a CLI date calculator with familiar syntax:

$ p 'S DateTime->today->add(days=>92)->ymd'
2013-03-31

As you see, there is no need to declare DateTime (it wasn't pre-declared, either!)
S is a shortcut for say. There are several others:

The script os very simple, if you miss any idiosyncrasy of yours, don't hesitate to fork it and customize it :)