我有以下脚本:
# Find any connection alerts to report
for my $Alert (@Alerts)
{
print " $Alert->{type} alerts:\n";
print STDERR "Query: [\n$Alert->{query}]\n";
my $alertCur = $dbh->prepare($Alert->{query})
or die "Unable to prepare cursor for [$Alert->{query}]: $DBI::errstr\n";
$alertCur->execute()
or die " Unable to execute cursor: $DBI::errstr\n";
while (my $rec = $alertCur->fetchrow_hashref())
{
#already in alert, don't send
next if (defined $rec->{alert_id});
print $fh "Location Alert Notification: $Alert->{type} for Site $rec->{location_id} elapsedTime(D HH:MM): $rec->{diff_tm}\n";
print "Location Alert Notification: $Alert->{type} for Site $rec->{location_id} elapsedTime(D HH:MM): $rec->{diff_tm}\n";
$dbh->do ("($Alert->{alert_id}, $rec->{location_id}, $rec->{imperial_site_id}, current)") or die "Unable to insert alert: $DBI::errstr\n";
$alertCnt++;
}
}
$dbh->disconnect();
if ($alertCnt > 0)
{
print "Found <$alertCnt> alerts!\n";
}
else
{
print "No alerts found!\n"
}
print "Finished processing, elapsed seconds <" . (time() - $startTime) . ">\n";
exit(0);
我试过了:
ps -ef|grep myscript.pl|grep $alertCnt grep
返回:
52642 117527 0 11:15 pts/63 00:00:00 grep myscript.pl
$alertCnt
是存储已发生警报数量的变量。我想计算变量$alertCnts
给出的警报数量。命令的正确使用方法是什么得到警报计数的数量?。
答案 0 :(得分:0)
请记住,Perl有一个非常灵活的内置grep函数。您可以在花括号之间嵌入任何您喜欢的perl语句,如下所示:
<input readonly id="select_email" (click)="select_email()" value="XYI.runme@previews.emailaddress.com">
select_email() {
var select_email = <HTMLInputElement>document.getElementById('select_email');
select_email.select();
var successful = document.execCommand('copy');
}