9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] awk, connect a string to a variable or a function
@ 2012-12-20  7:44 Rudolf Sykora
  2012-12-20  8:41 ` dexen deVries
  0 siblings, 1 reply; 3+ messages in thread
From: Rudolf Sykora @ 2012-12-20  7:44 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

awk doesn't have arrays with array members, which is what I now need.
However, if I could make some connection between a string, e.g. "foo"
and an array 'foo', this would be enough. I reckon gawk can do sth. like
that. But is there any possible workaround in the traditional awk?

Can anybody comment on this?
Thanks!
Ruda



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] awk, connect a string to a variable or a function
  2012-12-20  7:44 [9fans] awk, connect a string to a variable or a function Rudolf Sykora
@ 2012-12-20  8:41 ` dexen deVries
  2012-12-20 14:58   ` Rudolf Sykora
  0 siblings, 1 reply; 3+ messages in thread
From: dexen deVries @ 2012-12-20  8:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thursday 20 of December 2012 08:44:36 Rudolf Sykora wrote:
> Hello,
> 
> awk doesn't have arrays with array members, which is what I now need.


how about using two-level array?

BEGIN {
	a["foo",1] = "abc"
	a["foo",2] = "pqr"
	a["foo",3] = "xyz"
	a["bar",1] = "B1"
	a["bar", 2] = "B2"
	a["bar", 3] = "B3"
	for (i in a)
		if (i ~ "foo")
			print a[i]
}



hope that helps,
-- 
dexen deVries

[[[↓][→]]]


Reality is just a convenient measure of complexity.
                -- Alvy Ray Smith



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] awk, connect a string to a variable or a function
  2012-12-20  8:41 ` dexen deVries
@ 2012-12-20 14:58   ` Rudolf Sykora
  0 siblings, 0 replies; 3+ messages in thread
From: Rudolf Sykora @ 2012-12-20 14:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 20 December 2012 09:41, dexen deVries <dexen.devries@gmail.com> wrote:
> how about using two-level array?

Really, I finally flattened the arrays into one. Not exactly as you
wrote, but it did the trick.

Thanks!
Ruda



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-20 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-20  7:44 [9fans] awk, connect a string to a variable or a function Rudolf Sykora
2012-12-20  8:41 ` dexen deVries
2012-12-20 14:58   ` Rudolf Sykora

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).