The next time I need awk or sed, whatever I end up writing I’ll submit to chat gpt and ask it to rewrite it in perl so I can compare. I’m curious because so many people (well, enough people anyway) speak so highly of perl’s text processing capabilities. If it’s such a great tool, then I want to use it too.
Edit: one plus is that perl is as ubiquitous as awk and sed. It was there the whole time and I didn’t even realize it!
This sounds interesting!
The main reason I moved to perl instead of sed or AWK is for better control. Shell scripts don’t differentiate between variables and data (anyone else still having nightmares from trying to escape quotes and meta chars in a shell?).
Perl gives you all the simple features from sed or AWK and adds useful (maintainable) foreach iterators, arrays, hashes, etc.
Recommend using Strict mode if you are new to Perl. It gives good guardrails against silly mistakes like not declaring or misspelling a variables, or accessing strings or numbers that aren’t the correct datatype.
Thank you for the tip re: strict! Escaping - that's definitely a sore point. I feel like I get tripped up by embedded double quotes way too often - does perl have a good way to handle them?
Edit: one plus is that perl is as ubiquitous as awk and sed. It was there the whole time and I didn’t even realize it!