[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: awk info page should mention how to do case/switch in awk
From: |
Aharon Robbins |
Subject: |
Re: awk info page should mention how to do case/switch in awk |
Date: |
Mon, 4 Jun 2001 15:43:57 +0300 |
Thanks for the note.
> File: gawk.info, Node: Statements
> there should be a paragraph about "looking for a switch/case statement
> in awk? Sorry, there is none. The best way to get the same effect
> however, would be ...."
I've had this kind of report before. The problem with trying to list
things that *aren't* in gawk is that it's an infinite set. Looking for
Ada packages? Nope. What about calling functions through pointers? Nope.
What about perl's open_bottle_with_corkscrew() function? Nope.
Ad infinitum.
It's not worth it. If you've read the doc, and you didn't see it described,
it's not in the language.
> By the way, there it says
> "... highlights one of the greatest weaknesses in
> `awk', which is that it is very poor at manipulating single
> characters.
The newest version of the doc says "weaknesses in standard awk".
> By the way, is the actual answer just "if()else if()else if()..." or for(i in
> array)something something...?
if ... else if ...
> By the way, also the shell "shift" command for making $n = $n+1, also
> tell us how to do that in awk in the manual.
See above. Awk isn't shell. You can delete arguments one at a time
delete ARGV[i]
or write a loop to move them down one. But the shell "shift" style
of programming really doesn't apply a lot in awk, more typically one
uses
for (i = 1; i < ARGC; i++)
do something with ARGV[i]
If you mean the fields, the same applies, although I suppose it's
pretty easy to accomplish the "throw the first one away" with:
$1 = ""
$0 = $0
Thanks,
Arnold