Hi Monks,
I need to search a db table using some account numbers and at the end I need to attach the account numbers to its id, but having problems trying to store the data into a hash to use it later, I think, looking at this sample code will probably tell more from the comments, thanks:
######################### #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:::: #########################

Thanks for the Help!!!

In reply to Array or Hash problem! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.