associate array problems in awk

hi,
i have 3 fields in a file and linked them through 2 associative arrays.. the problem is one of the associative array is working while the other is not.. the code part is:
awk ' BEGIN {
FS="|"
rc = getline < "ICX_RULES"

while \( rc == 1 \)
\{
	rule_id=$1
	rule_parameter=$2
	rule_length=$3
	lengthofCallingNumber[rule\_length]=rule_parameter
	ruleCondition[rule\_parameter]=rule_id
	print lengthofCallingNumber[10]
	print ruleCondition[044]
	rc = getline &lt; "ICX_RULES"
\}

}

a sample of the file "ICX_RULES" is :
ICX-1|044|13
ICX-2|X1|10

although print lengthofCallingNumber[10] is giving result as: X1
but, print ruleCondition[044] is not yeilding any result.
please help, and please avoid use of if condition as a part of your solution

Try this way:

awk -F\| '
{
rule_id=$1
rule_parameter=$2
rule_length=$3
lengthofCallingNumber[rule_length]=rule_parameter
ruleCondition[rule_parameter]=rule_id
}
END{
print lengthofCallingNumber[10]
print ruleCondition[044]
}' ICX

Indexes are take as strings, so you must use the following syntax :

print ruleCondition["044"]

When you want to force integer indexes, you can do :

lengthofCallingNumber[rule_length+0]=rule_parameter

Another way to code your awk program :

awk -F\| '

NR==FNR {
   rule_id        = $1
   rule_parameter = $2
   rule_length    = $3

   lengthofCallingNumber[rule_length] = rule_parameter
   ruleCondition[rule_parameter]      = rule_id

   next
}

{
  # Proceed record from other_file
}

END {
   print lengthofCallingNumber[10]
   print ruleCondition["044"]
}

' ICX_RULES other_file

Jean-Pierre.