#!/usr/bin/perl -l
use strict;
use warnings;
my @str = split /\n/, <<'HTML';
| Security Code Matched | foo |
| Security Code Matched | N/A |
| Security Code Matched | N/A |
| Security Code Matched | 10! |
| Security Code Matched | N/A |
HTML
for (@str) {
if ( m{
\bSecurity\ Code\ Matched\b
(.*?)
(?(?{ index($^N, 'N/A') < 0 })!)
}xsg
) {
print "[[$_]]";
}
}