http://www.perlmonks.org?node_id=1020369


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

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