in reply to Re: Re: Re: Re: sort array by value in it
in thread sort array by value in it

First, get those IP addresses off a public site. Think before you post!

Second, you didn't understand the code I provided.

  1. Why are you setting $_ in the first line of the loop?
  2. Check your intendation in the map. It looks like you think the regex and hashref are part of the foreach-loop, not the map.
  3. This will provide a line in @out for each line in @lines. Make sure that's what you want.
  4. This will not skip lines as you were doing with the if-statement. Personally, I would do that kind of parsing in the do_it() function. But, you can do it in the map.
@lines = map { /(\/\w+\/\w+)\s+\w+\s+\d+\s+\d+\s+(\d+)\s+(\d+)%/; if ($1) { { volume => $1, available => $2, free => 100 - $3, } } else { () } } split(/\n/, $space{$host});

I hope you're testing this in some test environment ...

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested