bug-gnu-utils
[Top][All Lists]
Advanced

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

FW: SPLIT function changed?


From: Bill Brown
Subject: FW: SPLIT function changed?
Date: Fri, 27 Apr 2001 11:14:22 -0400

I found these email addresses from GAWK. I am running WIN98 2nd 4.10.2222A.

Seems like I use the SPLIT function in several AWK files and they're all
broke. Help????

-----Original Message-----
From: Bill Brown [mailto:address@hidden
Sent: Tuesday, April 24, 2001 1:31 PM
To: address@hidden
Subject: SPLIT function changed?


I have a data extraction AWK program dated 5/15/2000 that has been working
(It's in a ZIP file for safe keeping) I recently ran it with surprising
results for the SPLIT function.

I expect SPLIT($0, ff, ",") to split $0 (which is CSV format) into tokens
with the first token in ff[1], the second in ff[2], etc. Not exactly.
Consider:
        N=split($0, ff, ",")
        for (i in ff) print i, ff[i]

When $0 has more than three tokens the order is 4, 5, ... N, 1, 2, 3. I have
a test program that exhibits this behavior. See attached test.awk and
test.txt -- test.txt is the output from
        gawk -f test.awk > test.txt

A work around seems to be
        j=1
        while (j in ff) { j++ }
        for (i=1; i<j; i++) print i, ff[i]

Any explanations?

Attachment: test.txt
Description: Text document

Attachment: TEST.AWK
Description: Binary data


reply via email to

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