Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
associative arrays, ip addresses as keys?
- X-seq: zsh-users 5169
- From: Jason Price <jprice@xxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: associative arrays, ip addresses as keys?
- Date: 15 Jul 2002 09:54:56 -0400
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
I'm trying to use associative arrays to match a counter to different IP
addresses. I thought the following would do it:
set -A repeats
..... | while read ip count ; do
repeats[$ip]=repeats[$ip]+$count
done
however, when I try this, I get a floating point exception. I assume
zsh interprets the ip as a float.
I can do the following:
repeats=(10.2.1.1 7 10.2.2.1 9 10.2.3.1 52)
however, I can't get the results back either: echo $repeats[10.2.1.1]
What am I doing wrong? The manpage states that anything within the
square brackets will be subjected to arithmatic evaluation, even assoc
arrays. Is there an easy way?
Thanks;
Jason
Messages sorted by:
Reverse Date,
Date,
Thread,
Author