Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
######################### #original account numbers my @code_array = qw(7772344 2233421 TMW2222987 TMA2222333 TMW9999988 A +MQ8873332 AMQ1111877); #account numbers in @code_array has been processed and the letters bef +ore any account has been removed, so I have this: my @code_array_noletter = qw(7772344 2233421 2222987 2222333 9999988 8 +873332 1111877); my $plc_holders = join ( ',', ('?') x @code_array_noletter ); #this table is numeric, letters has been removed from account numbers my $databasse_cheks="SELECT accounts, id FROM accountstable WHERE acco +unts IN ($p_holders_state)"; # assuming all db stuff like connection,prepare,execute has been done +at this point while (my $pt = $sth->fetchrow_hashref) { my $accountnumber = $pt->{'accounts'}; my $acc_id = $pt->{'id'}; #matching account numbers in @code_array at the numeric level, w +ith what was found in the DB::: if ( "@code_array" =~ /(^|\s|[[:alpha:]]{0,3})$accountnumber(\s| +$)/ ) { # in here I need to store the acc_id the match what was +found in the @code_array. # matching on these account numbers as an example, 77723 +44 2233421 TMW2222987 i have to attache # the acc_id to it. And that's my problem. # I think it has to be done using a hash but having prob +lems trying. # results before storing in a hash or some other way, wi +ll be the account number and its id: # 7772344 34 2233421 54 TMW2222987 66 # need to push all this here to get access out side of t +he while } #print here for testing the results:::: #########################
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array or Hash problem!
by jethro (Monsignor) on Mar 04, 2010 at 17:55 UTC | |
by Anonymous Monk on Mar 04, 2010 at 18:28 UTC | |
by jethro (Monsignor) on Mar 04, 2010 at 19:04 UTC | |
|
Re: Array or Hash problem!
by spazm (Monk) on Mar 04, 2010 at 18:05 UTC | |
by Anonymous Monk on Mar 04, 2010 at 18:49 UTC | |
|
Re: Array or Hash problem!
by youlose (Scribe) on Mar 04, 2010 at 18:00 UTC | |
by Anonymous Monk on Mar 04, 2010 at 18:04 UTC | |
by youlose (Scribe) on Mar 04, 2010 at 18:34 UTC | |
by Anonymous Monk on Mar 04, 2010 at 18:54 UTC | |
by youlose (Scribe) on Mar 04, 2010 at 19:28 UTC |