in reply to Re: Regular Expression - print out certain sections of line based on the content
in thread Regular Expression - print out certain sections of line based on the content

"remove space after "FIRST'" ++

But the output from your code above is:

IJK1234 Use of uninitialized value in print at F:\_wo\pl_test\733761b2.pl line + 16. ABCD Use of uninitialized value in print at F:\_wo\pl_test\733761b2.pl line + 16.

...which doesn't capture the phone number.

So, perhaps one might wish to capture the phone in the manner below and avoid the uninitialized warnings re the case where "FIRST" is empty:

foreach my $item(@strings) { print "in ENV Not Running: " . $1 if ($item =~ /ENV\(([^)]*)\) STATU +S\(Not Running\)/); $item =~ /^PRINT NAME FIRST\(([^)]*)\).* PHONE\((.+)\)/; if ($1 && $2) { print "in PRINT NAME FIRST: $1, " . $2; } }

OUTPUT:

in ENV Not Running: IJK1234 in PRINT NAME FIRST: ABCD, 12345678

Note that adding the labels to the output may bollix further processing, depending on where OP is going with this.