News for hackers. Stuff that matters.
Re:The State of the Awk (2020) by jabl on Thursday January 19, 2023 @07:05AM (#34439445)
IMHO the nice thing about sed&awk is that a quick cheatsheet that covers most usage fits nicely on one page. Perl, in contrast, is more a 'proper' language and the Camel book is a pretty chunky tome. If you're going through all the trouble of learning a language in that space, you might as well go with something like python. Though admittedly python isn't a very good sed/awk replacement.
Re:The State of the Awk (2020) by kqr on Thursday January 19, 2023 @07:35AM (#34439643)
Who said you had to learn the entirety of Perl? I've been using Perl as an awk replacement for soon five years and I barely know a lick of Perl outside of what I need to use it as awk. If you use it that way, it's a much smaller language.

(That said, I do still have the tabs of perldata, perlobj, perlmod, and perlop open because I want to learn it better.)

Re:The State of the Awk (2020) by rtpg on Thursday January 19, 2023 @08:47AM (#34440181)
What does this look like in practice? Does Perl have a similar control flow syntax to awk?
Re:The State of the Awk (2020) by jrumbut on Thursday January 19, 2023 @10:22AM (#34441244)
It actually does (to an extent). There are BEGIN and END blocks (not used that much in regular scripting but they exist). There are also a bunch of perl command flags that can make things more awk-ish or sed-ish.

This random blog post gives something of the flavor.

https://lifecs.likai.org/2008/10/using-perl-like-awk-and-sed...

Re:The State of the Awk (2020) by kqr on Thursday January 19, 2023 @10:50AM (#34441597)
There's one fairly obvious error in that article: the fields are $F[0] etc, not @F[0]. Otherwise yes, that's a good way to make Perl look like awk. I personally translate awk concepts to more idiomatic Perl (I had no idea about -MEnglish, for example) but the concepts are still the same.
Re:The State of the Awk (2020) by jrumbut on Thursday January 19, 2023 @12:52PM (#34443271)
You're right, but it will still work as written.