Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Re: Resource for command line "one-liner" interpretation by hv
in thread Resource for command line "one-liner" interpretation by Hagbone

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (4)
    As of 2018-01-22 10:58 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (233 votes). Check out past polls.