2 ms·
For simple tasks, Awk is more concise than Perl. While you can write on one line of Perl anything that you can write in one line of Awk, the Perl line will be
by adrian_b 5y ago
For simple tasks, Awk is more concise than Perl.
While you can write on one line of Perl anything that you can write in one line of Awk, the Perl line will be longer.
So for the simple tasks that you would do from the command line or in a shell script, you can usually save time when writing for Awk.
For complex tasks, where you need more complex control than the implicit loop of Awk and you also need to define various extra variables besides those pre-defined, Awk is no longer more concise.
Then obviously Perl or other scripting languages become more convenient.
- adrian_b 5y agoTo give a quantitative value to what I mean by "more" concise, I have once written a very simple script to find some hash collisions in some files, both in Awk and in Perl. The Awk variant had 350 bytes, while the identical Perl variant had 450 bytes. The extra length in Perl was due to "$" prefix on all variables, an extra "split()" and an extra "while()", which were not needed in Awk. For slightly simpler versions of those scripts executed as one-liners, the difference in length was even much more in favor of Awk, because Perl needed extra command-line options to execute the script in the command line, while that is the default behavior of Awk.