I am trying to write this script in Perl to check for a unique string inside the variable $summary from my query results. There is multiple similar entries like this but part of them are unique (db1node1web1 could be different nodes but same result type). This is only a small part of the code to check if I using Reg Ex correctly (not true currently).
I included the code below:
$summary = "NFW - CRITICAL CPU_Load_db1node1web1 CRITICAL - load average: 114.49, 48.55, 29.17 Sept 01 00:10:16 PDT 2012";
if ( $summary =~ "NFW - CRITICAL CPU_Load_[a-z]* CRITICAL - load average: 114.49, 48.55, 29.17 Sept 01 00:10:16 PDT 2012") {
print "True\n";
}else {
print "False\n";
}
I am very bad with Perl and trying to get this working so I can dissect my query results.
It’s been a few years since I’ve coded in perl, but IIRC, don’t you have to specify whether it’s a match or substitution? And you need to include numbers
I believe your code should be:
Reference: http://www.troubleshooters.com/codecorn/littperl/perlreg.htm