bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] fatal: split: second argument is not an array


From: Hermann Peifer
Subject: [bug-gawk] fatal: split: second argument is not an array
Date: Thu, 21 Mar 2013 22:57:49 -0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

Hi,

I tried to split fields 1, 2 and 3 into arrays a[1], a[2] and a[3] respectively, see the below example (1). I ended up with the above-mentioned fatal error and I wonder if the error is correct as the identifiers a[1], a[2] and a[3] have never been used before. So in my (potentially wrong) understanding, they are "untyped", which means they could be either used as a scalar variable or as an array.

I got around the fatal error by initialising a[1], a[2] and a[3] as arrays, see (2), but I wonder if this hack should really be necessary.

Thanks in advance for your time,

Hermann

(1)

$ echo "a b/c d/e/f" | awk -i walkarray '{for (i=1;i<=NF;i++) split($i,a[i],"/"); walk_array(a)}' awk: cmd. line:1: (FILENAME=- FNR=1) fatal: split: second argument is not an array

(2)

$ echo "a b/c d/e/f" | awk -o -i walkarray '{for (i=1;i<=NF;i++) {a[i][0];split($i,a[i],"/")} walk_array(a)}'
[1][1] = a
[2][1] = b
[2][2] = c
[3][1] = d
[3][2] = e
[3][3] = f



reply via email to

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