bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Access variables not conforming to the variable naming co


From: arnold
Subject: Re: [bug-gawk] Access variables not conforming to the variable naming convention?
Date: Mon, 03 Dec 2018 07:10:30 -0700
User-agent: Heirloom mailx 12.5 7/5/10

> Hmmm, I think he may have something like this in mind:
>
> bash-4.2$ cat inp
> name,age,weight
> John,23,150
> Hilda,17,110
> bash-4.2$ gawk -F, '
> > NR == 1 {
> >    for (i = 1; i <= NF; i++)
> >       SYMTAB[$i] = i
> >    next
> > }     
> > 
> > $age >= 20 {
> >    print
> > }' inp
> John,23,150
>
> Are you disabling that ability to create the variable by poking it into SYMTAB

**** THERE IS NO SUCH CAPABILITY ****.  The fact that you reference 'age'
in the program is what puts it into SYMTAB.

Your program creates unrelated (non-variable) elements in SYMTAB "name"
and "weight" that are no different from any other array elements.

It is exactly this confusion that I'm trying to avoid.

Arnold



reply via email to

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