Im trying to learn hashes and hitting a snag. Here is what i want to do is have server1 and server2 which are both part of cluster1 and server3 and server4 which are part of cluster2. I want to take cpu(using extract command to get my cpu info) gather it from server1 and server2 and then get total by adding them together as a cluster( in the example cluser1). My problem is I want to print like this: cluster 1 cpu avr is 15.00% cluster2 cpu avr is 10.00% How do I gather the info separtely (i have to remsh to each server to get cpu info) and then push them back to know what cluster they belong too. Here is what ive tried.

%servers = ( 'server1' => 'cluser1', 'server2' => 'cluser1', 'server3' => 'cluser2', 'server4' => 'cluser2' ); foreach $key ( keys(%servers)){ push(@(values(%servers)); }
From here i would do the rest of the script. except this fails. sorry for any typo i trying to remember this from memory. any help would be appreciated.

In reply to clusters with hashes by Anonymous Monk

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.