Ok, but I deleted my answer as I just noticed that you are looking for the next column, not next row. My example would only have helped if you were looking for rows.
I am parsing a line that has "foo" over and over again on the same line. When using this script example, it gets the first "foo" plus one column over.
But then it stops processing that line. The lines look something like this:
this is the entry foo bar1 and perhaps foo bar2 or foo bar3
this is the entry foo bar2-1 and perhaps foo bar2-2 or foo bar3-3
this is the entry foo bar3-1 and foo bar3-2 maybe or foo bar3-3
so the current output from the adaptation above looks like:
type bar1
type bar2-1
type bar3-1
But I need to parse every column after foo on each line. So that my output would look more like:
type bar1
type bar2
type bar3
type bar2-1
type bar2-2
type bar2-3
type bar3-1
type bar3-2
type bar3-3
Why not just use 'foo' as your field separator? Then every field except the first will have what you want right at the beginning, no need to check every field or mess with match(). You'll need to do the splitting yourself, but for the trouble saved it's worth it.
$ awk -v FS="foo" '{ for(N=2; N<=NF; N++) { split($N, A, " "); print "type", A[1]; } }' data
type bar1
type bar2
type bar3
type bar2-1
type bar2-2
type bar3-3
type bar3-1
type bar3-2
type bar3-3
$