yea tried to understand the code before i used it think i understand it.
here is what i plugged it into..
it just a simpole script that uses mobile agents to relocate to another machine then run the code in do_it on that machine and returns a scalar containg the contents of df -Tm
these are then stored in a hash this is done for a couple of machines then the contents of the hash must be sorted to display a ranked listing of the machines with the most space available
#! /usr/bin/perl -w # # drivespace # use strict; use Mobile::Executive; my %space; ###################################################################### +###################################################### sub do_it { return scalar `df -Tm`; } ###################################################################### +####################################################### relocate( 'xxx.xxx.xxx.xxx', 2001 ); $space{ 'xxx.xxx.xxx.xxx' } = do_it; relocate( 'xxx.xxx.xxx.xxx', 2001 ); $space{ 'xxx.xxx.xxx.xxx'} = do_it; #relocate( 'xxx.xxx.xxx.xxx', 2001 ); #$space { 'xxx.xxx.xxx.xxx'}= do_it; #relocate( 'xxx.xxx.xxx.xxx', 2001 ); #$space = { 'xxx.xxx.xxx.xxx'}do_it; #relocate( 'xxx.xxx.xxx.xxx', 2001 ); #$space = { 'xxx.xxx.xxx.xxx'}do_it; relocate( 'xxx.xxx.xxx.xxx', 2001 ); my $counter = 1; my @out; my @lines; my $disk_used = 0; my $free = 0; print "host:volume available(MB) %free\n"; foreach my $host (keys %space) { $_ = $space{$host}; @lines = map { /(\/\w+\/\w+)\s+\w+\s+\d+\s+\d+\s+(\d+)\s+(\d+)%/; { volume => $1, available => $2, free => 100 - $3, } }split /\n/,$space{$host}; #This is the sorting line! @lines = sort { $b->{available} <=> $a->{available} } @lines; push @out, "$host:$_->{volume} $_->{available} $_->{free +}%" for @lines; }

Edited by Chady -- removed real IPs


In reply to Re: Re: Re: Re: sort array by value in it by Anonymous Monk
in thread sort array by value in it 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.