As mentioned it actually does have modes that assume various loops over the input. But it also has a bunch of syntax that naturally lends itself to that kind of very-narrow-text-dsl kind of code. Things like implicit variables, "postfix if", BEGIN/END blocks, all make awk-like just as easy to express as in awk. And then you add on top of that a much more capable base engine (despite awk's reliance on regex matching, it's still stuck with regular unix extended expressions) and library ecosystem.
Again, in 1998, in the early perl 5 era, you'd be looked at as a nut if you seriously tried to argue for doing some new tool in awk, even a tiny script. Everything worked better in perl.
It has options to split up input into fields and loop over every line for one-liners, yeah. For a trivial example,
awk '{ print $2 }' foo.txt
becomes
perl -lane 'print $F[1]' foo.txt
I'm one of those people who out off learning awk for a decade+ because I knew perl, but when I finally picked it up I found it's often simpler and cleaner. I still switch to perl for complicated processing but awk can get a lot done.
As mentioned it actually does have modes that assume various loops over the input. But it also has a bunch of syntax that naturally lends itself to that kind of very-narrow-text-dsl kind of code. Things like implicit variables, "postfix if", BEGIN/END blocks, all make awk-like just as easy to express as in awk. And then you add on top of that a much more capable base engine (despite awk's reliance on regex matching, it's still stuck with regular unix extended expressions) and library ecosystem.
Again, in 1998, in the early perl 5 era, you'd be looked at as a nut if you seriously tried to argue for doing some new tool in awk, even a tiny script. Everything worked better in perl.
It has options to split up input into fields and loop over every line for one-liners, yeah. For a trivial example,
becomes I'm one of those people who out off learning awk for a decade+ because I knew perl, but when I finally picked it up I found it's often simpler and cleaner. I still switch to perl for complicated processing but awk can get a lot done.