[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible bug in array handling after end of input (END handler)
From: |
Christian Schmidt |
Subject: |
Re: Possible bug in array handling after end of input (END handler) |
Date: |
Sat, 5 Dec 2020 18:34:57 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 |
Hi Andrew,
On 04/12/2020 20:10, Andrew J. Schorr wrote:
> Hi,
>
> On Fri, Dec 04, 2020 at 03:28:54PM +0100, Christian Schmidt wrote:
>> function dump() {
>> for (i in vars) printf ("%s:%s ", i, vars[i]);
>> print;
>> delete vars;
>> }
>
> Why are you calling "print" after dumping the contents of the vars
> array? It prints out $0. You are getting confused by that.
> If you modify the function like so, the problem should become obvious
> to you:
Thank you for this explanation. Given the normal trigger lines are
blank, it there only prints the newline as I expected. You are right
that this combination was confusing me.
> function dump() {
> for (i in vars) printf ("%s:%s ", i, vars[i])
> printf "\n"
> print "And I'm also printing $0 here for some unknown reason"
> print
> delete vars
> }
>
> Also, FYI, you don't need those semicolons at the end of each line.
> A semicolon is needed only to separate two statements that are on
> the same line (and not separated by a linefeed).
I am aware; it's just a habit.
Thank you again and best regards,
Chris
> Regards,
> Andy
>