* associative arrays, ip addresses as keys?
@ 2002-07-15 13:54 Jason Price
2002-07-15 14:05 ` Sven Wischnowsky
0 siblings, 1 reply; 2+ messages in thread
From: Jason Price @ 2002-07-15 13:54 UTC (permalink / raw)
To: zsh-users
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: associative arrays, ip addresses as keys?
2002-07-15 13:54 associative arrays, ip addresses as keys? Jason Price
@ 2002-07-15 14:05 ` Sven Wischnowsky
0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2002-07-15 14:05 UTC (permalink / raw)
To: zsh-users
Jason Price wrote:
> 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
Change this line to `typeset -A repeats'.
Bye
Sven
--
Sven Wischnowsky wischnow@berkom.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-07-15 14:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-15 13:54 associative arrays, ip addresses as keys? Jason Price
2002-07-15 14:05 ` Sven Wischnowsky
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).