in reply to Array or Hash problem!

I have difficulties understanding your problem since there seem to be words missing in your problem description: "in here I need to store the acc_id the match what was found in the @code_array"

Apart from correcting above sentence you could answer the following question to shed more light on your problem: What would be wrong with the following solution:

$ids{$accountnumber}= $acc_id;

or, if accountnumbers had more than one acc_id:

push @{$ids{$accountnumber}}, $acc_id;

Replies are listed 'Best First'.
Re^2: Array or Hash problem!
by Anonymous Monk on Mar 04, 2010 at 18:28 UTC
    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.

      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};