gawk into an array question

John Chambers jc-8FIgwK2HfyJMuWfdjsoA/w at public.gmane.org
Tue Jan 27 20:38:48 EST 2009


Eric Chadbourne wrote:
| you know what, awk is giving me pain.  i think you have just inspired me to write my first perl script.  we're running on linux and have perl installed.  i just glanced at the manual and it reminds me of php.  $ and ; and other familiar stuff.  thanks for the inspiration doug!

Careful there; perl is known to be highly addictive. ;-)

This example is one of the reasons, though perhaps not for the reason
that most people would guess.  Awk scripts can be easily converted to
perl, and are often simpler.  But the real reason is that awk can  be
quite  difficult  to debug.  It says "Bailing out in line 2", you say
"WTF???", and you tear your hair out trying to guess  what  you  said
that offended it.  Perl comes with an interactive debugger that's one
of the first things you should learn.  You can  install  breakpoints,
step  through  the  code, examine variables, modify them, and all the
usual stuff.  This is a huge relief after dealing with tools like awk
that  don't  help you at all.  Perl is a pretty good language in most
regards, but the real reason that people get addicted to it  is  that
it does things like this to make life easier for the programmer.

I often find myself starting to write a shell script,  and  8  or  10
lines  in  I  hit  something that makes me think "This would be a lot
easier in perl".  So I add a few dollar signs, semicolons and  braces
to make it into a perl script, and continue.


--
I ♡ Unicode





More information about the Discuss mailing list