Hi Gurus!

Here's what I'm trying to do : I have a database table that has rows for bugs against a few components in the system like so

COMP BUGNO ------ ----- USRINT 1111 HWARE 1232 USRINT 1021 KERNEL 4384 DRIVER 4894 KERNEL 4398 USRINT 1233

Now, I want to convert this data into a Perl Hash where in the "key" is the faulty component and the "value" is a list of bugs against that faulty component.

Now I have used DBI to get the values and write them to a hash like so

our $stmt = qq/select component, bug_no from request where status like + 'OPEN'/; our $sth = $dbh->prepare($stmt); $sth->execute() or die DBI->errstr; my %hash; while( my( $comp, $bug_num ) = $sth->fetchrow_array() ) { $hash{ $comp } = $bug_num; }

What's happening here is that data is being overwritten when a new bug comes against an existing component. I want this bug to be appended to the end of that list so that one print of this hash gives me a list of components and bugs that are open against that component like so:

USRINT 1111, 1021, 1233 HWARE 1232 KERNEL 4384, 4398 DRIVER 4894

I'm not able to get this done. Any help is appreciated!


In reply to Database Rows into Perl Hash by vishi

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.