Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

19
  • 3
    With respect to This can be done in awk, but IMO is much easier to do in perl - you keep posting about things being hard to do in awk when they aren't, please consider the possibility that you just are more familiar with perl and so may not be aware of the simple ways to do some tasks in awk. I find it vastly easier to do anything in awk than perl but I know that's because of my unfamiliarity with perl, not because of the tool/language. Commented May 14, 2021 at 15:02
  • @EdMorton The reason I keep saying that is because it's true. Many things are easier in perl, much easier, because perl has built-in functions (like join and map and splice) that make string and array handling easier - no need to write your own join function, or rewrite the same tedious for (i=1;i<=NF;i++) loops all the time. And then, there's the huge library of CPAN modules - how many lines of awk code would it take my own CSV or JSON or XML or HTML parser, for example - a lot more than just use Text::CSV, use JSON, etc. Nothing like CPAN exists for awk. Commented May 14, 2021 at 15:46
  • Please consider that YOU are just unfamiliar with perl. I'm very familiar with both awk (~30 years) and perl (25+ years), and know the strengths and limitations of both. There really are many things that are trivially easy to do in perl, that require significantly more effort copy/pasting & editing, or just retyping, the same boiler-plate code that you've used in that last few hundred awk scripts. I still write a lot more awk than perl, but mostly for simple stuff of a dozen lines or so. Anything more complex I'll do in perl because I can do it in a fraction of the time. Commented May 14, 2021 at 15:51
  • BTW, I didn't say "hard to do in awk". I said "much easier to do in perl". Those two sentences have different meanings. What I generally think about it is "some things are a PITA to do in awk, but not in perl". And I tell people "use perl" when it's appropriate for exactly the same reasons I tell people "use awk, not a shell while read loop" when that is appropriate. Use the right/best tool for the job. Commented May 14, 2021 at 15:54
  • 1
    @HaimontiDutta cool, teaching useful stuff was the reason I posted my answer. It's why I put in the effort to explain what the script does and how it does it and why - that's more important than just the code. Commented May 15, 2021 at 4:17