Q:

bash - colon in array key name

I'm trying to write a script in bash that does the same things for several instances of the same application - running on different ports. My current approach was to use an array like so:
INSTANCES=('localhost:50010' 'localhost:50011' 'localhost:50012')
for INSTANCE in ${INSTANCES[@]}; do
  A["$INSTANCE"]="$(do stuff with $INSTANCE)"
  B["$INSTANCE"]="$(do more stuff with $INSTANCE)"
done

Bash seems to reject this since there is a colon in the array key name:
bash: localhost:50010: syntax error in expression (error token is ":50010")

I guess that's got something to do with the Shell Parameter Expansion or something similar. Is there any way to achieve what I'm trying without manipulating the content of $INSTANCE?
Thanks in advance!

A:

Colon is very much accepted as array key name for associative array.
You just need to declare your associative arrays first:
declare -A A B

