hi wise monks i just wondering is there anyway to sort an array by a value contained within the array element
such as in the below result i want to have the array sorted by the available space on the volume.
host:volume available(MB) %free
149.153.130.11:/dev/hda3 10168 80%
149.153.130.11:/dev/hda2 84 90%
149.153.130.15:/dev/hda3 10168 80%
149.153.130.15:/dev/hda2 84 90%
where the out put is generated by
@lines = split(/\n/,$space{ $host });
shift @lines;
foreach $disk_used (@lines)
{
$_ = $disk_used;
if (/(\/\w+\/\w+)\s+\w+\s+\d+\s+\d+\s+(\d+)\s+(\d+)%/ )
{
$free = 100-$3;
push @out,"$host:$1 $2 $free%";
}
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.