i have some data in Mongo. I want to get keys from that like  keys $data{$date}{$err_id}{'Total_calls'} It works in perl hash. But how to get that from Mongo. I tried like this but not working.

for (my $priday=int($day); $priday >=1 ; $priday--) { my $old_print_date=sprintf('%02d-%02d-%04d',$priday,$month,$year); $date = sprintf('%02d%02d%04d',$priday,$month,$year); my $data = $collection->find({'date' => "$old_print_date"}); while (my $doc = $data->next) { $row = 1; $worksheet->write( $row, $col, sprintf('%0d', $doc{$da +te}{'Total'}{"305"}), $format2); $row++; $worksheet->write( $row, $col, sprintf('%0d', $doc{$da +te}{'Pre'}{"305"}), $format2); $row++; $worksheet->write( $row, $col, sprintf('%0d', $doc{$da +te}{'Post'}{"305"}), $format2); $row++; } }

Sample data

'27112015' => { '25' => { 'Total_calls' => { '11' => 11, '21' => 13, '17' => 44, '02' => 1, '22' => 18, '18' => 29, '08' => 11, '23' => 8, '16' => 22, '13' => 30, '06' => 1, '01' => 3, '12' => 20, '20' => 28, '14' => 18, '15' => 17, '07' => 2, '10' => 30, '19' => 28, '09' => 7 } }, 'Total' => { '25' => 341, '305' => 23 }, 'Post' => { '25' => 216, '305' => 23 }, 'Pre' => { '25' => 125 }, '305' => { 'Total_calls' => { '11' => 13, '15' => 10 } } }, 'date' => '27-11-2015'

In reply to Getting keys from Mongo DB by ravi45722

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.