bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] fatal: cannot assign to arbitrary elements of SYMTAB


From: Andrew J. Schorr
Subject: Re: [bug-gawk] fatal: cannot assign to arbitrary elements of SYMTAB
Date: Thu, 18 Apr 2019 08:38:16 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Wed, Apr 17, 2019 at 10:12:18PM -0500, Peng Yu wrote:
> You assume that the header must be a valid awk variable name. That is
> a too stringent condition. Not all headers satisfy this condition.
> 
> Also, people might want to specify the column name in the command line
> via `-v`. It is not possible to do so using your command.
> 
> > Why? How is it better than my revised version above which continues
> > to work fine? What's the usage case for assigning to arbitrary variable
> > names that are never used in the program?

Can you please share an example of what you're trying to do? I really don't
understand your paradigm. When I process a file that contains column headers, I
do something like this:

gawk '-F|' '
NR == 1 {
   for (i = 1; i <= NF; i++)
      m[$i] = i
   next
}

{
   printf "%s lives at %s\n", $m["name"], $m["address"]
}'

Is this the type of situation you're talking about?

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]