I am new in Perl. I have trying to below query

my $json = Cpanel::JSON::Dump( { 'dns_records' => [ map { ( { 'dns_rec +ord' => $_ } ) } @dns_record ] } );

After that getting below array

[{"dns_records": [ {"dns_record":{"ip":"192.64.179.9","ttl":"86400","name +":"86400","hostname":"192.64.179.10","type":"A"}}, {"dns_record":{"ip":"192.64.179.10","ttl":"14404","nam +e":"14400","hostname":"127.0.0.1","type":"A"}}, {"dns_record":{"ip":"@","ttl":"86400","name":"86400"," +hostname":"aresstest.com","type":"MX","mx_priority":"0"}}, {"dns_record":{"ip":"mail","ttl":"14400","name":"14401 +","hostname":"aresstest.com","type":"CNAME"}}, {"dns_record":{"ip":"www","ttl":"14400","name":"14402" +,"hostname":"aresstest.com","type":"CNAME"}}, {"dns_record":{"ip":"ftp","ttl":"14400","name":"14403" +,"hostname":"aresstest.com","type":"CNAME"}}]}]

But I need below type of array

[{"dns_record":{"ip":"192.64.179.9","ttl":"86400","name":"86400","host +name":"192.64.179.10","type":"A"}}, {"dns_record":{"ip":"192.64.179.10","ttl":"14404","nam +e":"14400","hostname":"127.0.0.1","type":"A"}}, {"dns_record":{"ip":"@","ttl":"86400","name":"86400"," +hostname":"aresstest.com","type":"MX","mx_priority":"0"}}, {"dns_record":{"ip":"mail","ttl":"14400","name":"14401 +","hostname":"aresstest.com","type":"CNAME"}}, {"dns_record":{"ip":"www","ttl":"14400","name":"14402" +,"hostname":"aresstest.com","type":"CNAME"}}, {"dns_record":{"ip":"ftp","ttl":"14400","name":"14403" +,"hostname":"aresstest.com","type":"CNAME"}}]

Please guide.


In reply to Re^6: How to read Array by sunilgame
in thread How to read Array by sunilgame

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.