4 ms·
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
by kqr 4y ago
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.)
- rtpg 4y agoWhat does this look like in practice? Does Perl have a similar control flow syntax to awk?
- jrumbut 4y agoIt 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.html https://lifecs.likai.org/2008/10/using-perl-like-awk-and-sed...
- kqr 4y agoThere'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.
- jrumbut 4y agoYou're right, but it will still work as written.