Awk: Matching Pattern From other file with length

Hi,
I have input file whose first column needs(match.txt) to be matched with the first column of the input file with min & max length as defined in match.txt. But conditions are not matching. Please help on the changes in the code below as for multiple enteries in match.txt complete match.txt will be iterated for every line

Inputfile.txt

 91560606,9132008926661208,20150501000000,S,MTS_TECHZONE,2470,405899136999995,ZTE_20150501000021.4723_MTPP.SMS,postpaid
915612345,9131689141500399,20150501000005,S,MTS_TECHZONE,2376,405899136999995,ZTE_20150501000021.4723_MTPP.SMS,postpaid
915606061,9131689141847478,20150501000008,S,MTS_TECHZONE,2377,405899136999995,ZTE_20150501000021.4723_MTPP.SMS,postpaid
91512130,9132009153417379,20150501000009,S,MTSCC_UTIBAOUT,2471,405899136999995,ZTE_20150501000021.4723_MTPP.SMS,postpaid
91512131,9131638459315908,20150501000009,S,MTSCC_UTIBAOUT,2A65,405899136999995,ZTE_20150501000021.4723_MTPP.SMS,postpaid
9151213,9131899152971817,20150501000001,S,MTSCC_UTIBAOUT,2A6A,405899136999995,ZTE_20150501000051.4724_MTPP.SMS,postpaid
9156060,9131639136042555,20150501000000,S,MTS_TECHZONE,2A65,405899136999995,ZTE_20150501000051.4724_MTPP.SMS,postpaid
91532320,9131878925486546,20150501000000,S,PHONEYTUNES2,2375,405899136999995,ZTE_20150501000051.4724_MTPP.SMS,postpaid

match.txt

 9156,4,10
 9151,4,7
 91532,5,10
 

Code

 awk -F, 'NR==FNR{SHTMINL[$1]=$2;SHTMAXL[$1]=$3;next}
 {
 for(i  in SHTMINL )
 {
 if($1 ~ /^(i)/ && length($1) <= SHTMAXL[$i] && length($1) >= SHTMINL[$i] )
 print
 }
 }
 ' match.txt inputfile.txt
 

Hi, Can you try to replace your "if condition" by:

 if($1 ~ "^"i && length($1) >=SHTMINL && length($1) <=SHTMAXL)

Regards.

You have two logical errors in your code snippet:
$1 ~ /^(i)/ : Slashes indicate regex constants, so the i is taken literally and not as a variable.
SHTMAXL[$i] : i is already the index into the array, set by the (i in array) construct. $i will try to use it as a field number and fail; you don't have 9000+ fields, and 91000 is way beyond field number limits (error msg: program limit exceeded: maximum number of fields size=32767)

Thanks all for the help