Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Resource for command line "one-liner" interpretation

by hv (Parson)
on May 15, 2003 at 02:02 UTC ( #258309=note: print w/replies, xml ) Need Help??

in reply to Resource for command line "one-liner" interpretation

The main thing to look at is perlrun, which will describe the command-line options to perl - understanding what options are available, and how they interact with each other, is crucial to writing and understanding one-liners.

Beyond that, it is just perl. One-liners tend to take shortcuts that make the perl less obvious to someone more used to application code - no strictures, heavy use of special variables (perlvar) and nasty tricks that would be more trouble than they're worth in a production/maintenance environment.

Another important aspect to grok is the Unix philosophy beyond perl - lots of tools that do (mostly) simple things and work well together. For example, this is an invocation I use remarkably often:

find . -type f | xargs perl -wle '... some code ...'
The power of perl knowledge is that you can add to this set - look out for things that you do regularly, and try to write tools to add to the set to reduce the amount of typing and, more importantly, thinking required to do your day to day tasks. And when you write such tools, treat them as applications rather than one-liners - perl is all about having the kitchen sink as well.

Taking it out of context, this article includes some short examples of the sort of utilities I'm talking about. But there's no reason your utilities need to be short - one of my most often used self-written utilities is 818 lines (including POD) and supports 19 distinct command-line options in around 25920 combinations.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://258309]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-06-21 15:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (118 votes). Check out past polls.