Rather than shifting @mylist and @mylist1, you can immediately shift @vmstat to get rid of the first record: saves you one shift operation and one loop through @vmstat.
It is not necessary to chomp $z when looping through @mylist and @mylist1 if you do not add the "\n" to the result of the split when looping through @vmstat: saves you two chomp operations.
You can even leave out the first chomp $x, as your split / /, $x will drop the EOL-character already.
Speaking of the split / /, $x: as you only need the fifth and sixth element of each record, why not saying:
(undef, undef, undef, undef, my $pos5, my $pos6) = split / /, $xAnd finally (at the risk of becoming obfuscated):
foreach (@vmstat) { # assigns to $_ (undef,undef,undef,undef,$pos5,$pos6) = split; # splits $_ on + whitespace push @mylist, $pos5; push @mylist1, $pos6; }
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: vmstat threshold script
by CountZero
in thread vmstat threshold script
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |