Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hi Rajsai2825,
I know you have been given a workable script, but I just want to point out that you can do all your "stuff" using just a hash and function unpack.
As shown below. (ofcourse, I wouldn't drop all the "jar of honey" on your laps!:))

use warnings; use strict; my %input; my $total; my $grand_total; while (<DATA>) { chomp; next if /^$/; my ( $k1, $k2, $k3, $k4, $k5 ) = unpack("x25 A10 A10 x1 A10 x1 A1 +x1 A5"); $total += $k4; $grand_total += $k5; push @{ $input{'summary'}{'Detial_Summary'}{$k1}{$k2}{$k3}{ ++$k4 +} }, $k5; } push @{ $input{'summary'}{'TOTAL'}{$total} }, $grand_total; use Data::Dump; dd \%input; __DATA__ Summary Detial_Summary EMC CHECK abcdefghi AZ_checker 1 20.32 Summary Detial_Summary EMC CHECK abcdefghi AZ_checker 1 24.00 Summary Detial_Summary EMC CHECK KBCDEFGHI AZ_checker 1 10.00 Summary Detial_Summary EMC CHECK KBCDEFGHI AZ_checker 1 14.00 Summary1 Detial_Summary1 EMC CHECK1 abcdefghi AZ_checker 1 20.59 Summary1 Detial_Summary1 EMC CHECK1 abcdefghi AZ_checker 1 24.00 Summary1 Detial_Summary1 EMC CHECK1 HGIJHKKIF AZ_checker 1 10.00 Summary1 Detial_Summary1 EMC CHECK1 HGIJHKKIF AZ_checker 1 14.00

OUTPUT
{ summary => { Detial_Summary => { "EMC CHECK" => { " abcdefghi" => { AZ_checker => { 2 => [20.32, + "24.00"] } }, " KBCDEFGHI" => { AZ_checker => { 2 => ["10.00 +", "14.00"] } }, }, "EMC CHECK1" => { " abcdefghi" => { AZ_checker => { 2 => [20.59, + "24.00"] } }, " HGIJHKKIF" => { AZ_checker => { 2 => ["10.00 +", "14.00"] } }, }, }, TOTAL => { 8 => [136.91] }, }, }
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

In reply to Re: Hashes of Hash in perl by 2teez
in thread Perl Hash by Rajsai2825

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    Tanktalus has to figure out why his cb talker isn't working :(
    [choroba]: https?
    [choroba]: That was at least why my cb talker wasn't working.
    [Tanktalus]: curious, then, why the reader works :)
    [Tanktalus]: or posting the last hour of cb... well, maybe I should double check that first :)
    [Tanktalus]: yup, it's working. :)
    [choroba]: https://github. com/choroba/pm-cb/ commit/7b57f513596 7bf8a29d74f1c307de 9a76894cdcf

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (7)
    As of 2018-07-15 21:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















      Results (326 votes). Check out past polls.

      Notices?