I still find that, after all these years, it's easier to write

ls -l|awk '{print $5}'

than

ls -l|perl -alne 'print $F[4]' or Newton forbid... ls -l|perl -ane 'print "$F[4]\n"'

Not only is the awk solution clearer, it also has a lighter resource footprint.

That is, when you string together long pipes on the command line, awk is often more compact than Perl. That's about all I use awk for these days, but I sure used to sling around a lot of data with it in the 80s.

It's not difficult to learn to write baby awk, and if you do it will serve you well. If the job gets too tough, though (think: you can no longer run it from the command line) then it's time to switch to Perl.

For example, user functions were retrofitted into the language, and the syntax is a bit of a botch. I can't even remember what it was now, but there was a gotcha that would rear its head up every so often and bite you.

Just because you have a chainsaw doesn't mean you can't use a pair of secateurs.



--
g r i n d e r

In reply to awk has its place by grinder
in thread AWK and Perl on UNIX by Zo

Title:
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, details, 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, summary, 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.