in reply to Help with storing data in a hash

%calls = &call_type( $d, $d );

There's your problem - you're only getting 1 day's worth of data because you're passing the same date as the start and end. Maybe you meant:

%calls = &call_type( $d, $d + 10 );

Not sure how your dates are stored though - that only works if they're epoch times or objects that know how to add.

If you mean you're calling call_type() multiple times and expecting the results to accumulate in %calls, you may want something more like:

%calls = (%calls, &call_type( $d, $d ));

-sam

Replies are listed 'Best First'.
Re^2: Help with storing data in a hash
by hallikpapa (Scribe) on Jan 28, 2008 at 22:26 UTC
    Well here's the dates:
    my @dates = ( '20080101', '20080102', '20080103', '20080104', '20080105', '20080 +106', '20080107', '20080108', '20080109', '20080110' );
    And for this specific procedure, it only wants one day. way the store procedure in the db is.
    foreach my $d (@dates) { %calls = &call_type( $d, $d ); } print Dumper \%calls;
    I followed your second suggestion and that worked. I appreciate the help.
      Aha - that's the important part! You're overwriting %calls each time you call that function. I added an example you can use to my answer above. A better solution would be to make call_type() accept a reference to %calls and add entries to it.

      -sam

      Hi hallikpapa

      You simply declare %calls in outside of the subroutine call_type like

      my %calls; foreach my $d (@dates) { %calls = &call_type( $d, $d ); }

      Punitha