Q:

Parsing of ip address from netstat output on MacOS with awk

This is an awk related question (no perl/cut/sed... please :) ).  
What I'm actually trying to do is to get the destination address from netstat output on MacOS using only awk. 
Here an example of the output:
$ netstat -nl -p tcp
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  127.0.0.1.26164        127.0.0.1.50100        ESTABLISHED
tcp4       0      0  127.0.0.1.50100        127.0.0.1.26164        ESTABLISHED

If I run the awk parser, I get :
$ netstat -nl -p tcp | awk '/tcp/ {split($5,a,".") ;  for(i=1; i<NF-1; i++) printf a[i] ".";  printf "\n"}'
127.0.0.1. 
127.0.0.1. 

1) Is there a way to remove the "."  at the end of the IP address? 
2) Is there a better "awk" way to obtain the same result? 
PS: I know you can type something like 
$ netstat -nl -p tcp | perl -ape '$_=$F[4];s/((?:\d+\.){3}\d+)\D.*/$1\n/'

to get the correct result ;)
Thanks! 

A:

Just play with the number of elements coming from split():
awk '/tcp/ {n=split($5,a,".") 
            ^-----------------------------------------------------------\
            for(i=1; i<n; i++) printf "%s%s", a[i], (i==n-1?"\n":".")    |
                       ^-----------------------------^^^^^^-------------/
           }'

Explanation

n=split($5,a,".")  split as you were doing, but storing in the variable n the amount of fields that this produces. 
for(i=1; i<n; i++) printf "%s%s", a[i], (i==n-1?"\n":".")}  loop through these values, printing either a dot .  or a new line depending on the loop time. 

Test
$ netstat ... | awk '/tcp/ {n=split($5,a,".");  for(i=1; i<n; i++) printf "%s%s", a[i], (i==n-1?"\n":".")}' 
127.0.0.1
127.0.0.1

