Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Trying to sort output

by fishmonger (Chaplain)
on Feb 23, 2013 at 20:16 UTC ( #1020339=note: print w/replies, xml ) Need Help??


in reply to Re: Trying to sort output
in thread Trying to sort output

I have as well, and for completeness, will post it here also.

#!/usr/bin/perl use strict; use warnings; use List::Util qw(max); my $rundsm = `dsmadmc -id=reports -pa=reports q proc`; my @seconds = $rundsm =~ /\((\d+)\s+seconds\)/mg; if (max(@seconds) >= 1001) { print "Message: Issue Found, Alert Operations\n", "Statistic: 1\n"; exit 1; } else { print "Message: No Issues Foun\n", "Statistic: 0\n"; exit 0; }

Replies are listed 'Best First'.
Re^3: Trying to sort output
by Kenosis (Priest) on Feb 24, 2013 at 01:08 UTC

    Here's a variant that doesn't require List::Util, as you can grep the captured seconds for values greater than or equal to a limit. The m modifier's not needed in the regex, since \s+ will match across lines:

    #!/usr/bin/perl use strict; use warnings; my $limit = 1001; my $rundsm = `dsmadmc -id=reports -pa=reports q proc`; if ( isIssue( $limit, $rundsm ) ) { print "Message: Issue Found, Alert Operations\n", "Statistic: 1\n" +; exit 1; } else { print "Message: No Issues Found\n", "Statistic: 0\n"; exit 0; } sub isIssue { my ( $limit, $data ) = @_; return grep $_ >= $limit, $data =~ /\((\d+)\s+?seconds\)/g; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020339]
help
Chatterbox?
marioroy just logged in to say that MCE::Hobo has passed testing and therefore will continue to run like threads but have managed capabilities similar to Parallel:: ForkManager. It allows multiple managed instances to run simultaneously. Zero limitations.
marioroy it's taken a long time to make this possible.
marioroy will post demonstrations after release

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-07-28 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (433 votes). Check out past polls.