I have multiple procedures that need to dump data into a hash (Well it's not necessarily a hash, but I would still like unqiue entries stored this way.). There is a range of dates stored in an array, and looping thru the array I do this:
%calls = &call_type( $d, $d ); sub call_type { #FIELD NAMES (name, calltype, calls, minutes, revenue, cost, margin) my ( $name, $calltype, $calls, $minutes, $revenue, $cost, $margin, + %calls ); my ( $day_start, $day_end ) = @_; my $sp = $msdbh->prepare( qq|usp_Dashboard_CallType \@start = '$day_start', \@end = '$da +y_end'|); $sp->execute or die( $sp->errstr ); while ( ( $name, $calltype, $calls, $minutes, $revenue, $cost, $ma +rgin ) = $sp->fetchrow() ) { $calls{ $day_start . ":" . $name } = [ "$calltype", "$calls", "$minutes", "$revenue", "$cost", "$ +margin" ]; } return %calls; }
So there should be 40 unique entries. 4 entries per day, 10 days. But right after I loop thru all of the days, I do a print Dumper \%calls; And get this
$VAR1 = { '20080110:Dedicated' => [ '1', '4722194', '12730293.0000', '65169.0000', '38247.000000', '41.311000' ], '20080110:Canada' => [ '4', '7898', '49191.0000', '168.0000', '248.000000', '-47.619000' ], '20080110:Directory' => [ '8', '18', '29.0000', '7.0000', '.000000', '100.000000' ], '20080110:Toll Free' => [ '5', '91114', '140912.0000', '-116.0000', '-703.000000', '-506.034400' ] };
Why is there only the last day/entry? thank you.

In reply to Help with storing data in a hash by hallikpapa

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.