Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Trying to sort output

by Laurent_R (Abbot)
on Feb 23, 2013 at 18:40 UTC ( #1020331=note: print w/replies, xml ) Need Help??

in reply to Trying to sort output

Hi, I have given you a proposed solution on your cross post on Perl Gurus.

Replies are listed 'Best First'.
Re^2: Trying to sort output
by fishmonger (Chaplain) on Feb 23, 2013 at 20:16 UTC

    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; }

      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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020331]
GotToBTru thinks erix & MySql ... talk about a database trigger
[GotToBTru]: wow .. outta votes and it's not even lunchtime yet
[stevieb]: berrybrew has been updated with the new perl checksums. Now I'm going to implement dynamic loading of perls thanks to their new JSON releases file

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (17)
As of 2017-03-30 15:53 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (360 votes). Check out past polls.