in reply to not getting desired output
You need to escape the square brackets since you want to match a literal [4], so instead of
try this:if($line =~ /Handling NSPAdvice for mechanism [4]/) { # the RE above would match "Handling NSPAdvice for mechanism 4"
Analogue:if($line =~ /Handling NSPAdvice for mechanism \[4\]/) { # alternative: if ( index($line,'Handling NSPAdvice for mechanism +[4]')>=0 ) {
...to...if ($line =~ /Authentication mechanism returned [[](\S*)[] +]/) {
HTHif ($line =~ /Authentication mechanism returned \[(\-?\d+) +\]/) { # the RE above would match e.g. [4] -> $1=4, [-10] -> $1= +-10, etc.
|
|---|