Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

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

I have a hash like this one :

my %result= ( '2005/12/15-01:00' => { 'c4t13d0' => '1751 1.0 67.2', 'c5t8d0' => '314 1.0 9.5', }, '2005/12/14-22:20' => { 'c4t12d0' => '1688 1.0 58.9', 'c5t12d0' => '1701 1.0 65.5 125 12.2 12 ', 'c5t8d0' => '545 1.0 12.2', 'c4t8d0' => '791 1.0 18.8' }, '2005/12/12-22:20' => { 'c4t12d0' => '1690 1.0 58.9', 'c5t12d0' => '1703 1.0 65.5', 'c5t8d0' => '566 1.0 13.3 12.36 321', 'c4t8d0' => '840 1.0 22.2' }, ) ;

What i want is the maximum number of numbers in the string ( which is the value of the hash ) .
I could record this number when i initialy load the hash (parsing a file) or loop over keys, but i though of using values, which proved interesting . Here is what i came up with :

my @list ; push @list, values %$_ for values %result ; my ($seen) = sort {$b<=>$a} map { my @tmp = split " ", $_ ; scalar @tmp } @list ; print $seen ;
I wonder if there are better / more efficient / more readable ways ?

Thanks for your advice


In reply to Max numbers of element in the values of an HoH by secret

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?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (5)
    As of 2020-04-06 23:43 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      The most amusing oxymoron is:
















      Results (42 votes). Check out past polls.

      Notices?