in reply to Re: Array or Hash problem!
in thread Array or Hash problem!

This $ids{$accountnumber}= $acc_id; is good, but:
"in here I need to store the acc_id the matchs what was found in the db with the acount number from the @code_array array". I am searching for "2222987" and I find in the db 2222987 the id 66 is also found, that's what it means storing the value into this hash. But how to keep the original account number like TMW2222987 instead of 2222987 and the id of course. Thanks.

Replies are listed 'Best First'.
Re^3: Array or Hash problem!
by jethro (Monsignor) on Mar 04, 2010 at 19:04 UTC

    So you want to have '2222987' as key and 'TMW2222987' and '66' as values? In that case you could use a two-element array or just concatenate the two values into a string:

    $ids{$accountnumber}= "$acc_id:$1$accountnumber";

    The $1 is what was matched with the first parenthesis in your regex, so should be 'TMW' or ' ' or '' or ...

    You get both values separated again with:

    my($acc_id,$fullaccount)= split /:/,$ids{$accountnumber};