Hopefully a relatively simple one for somebody, but I've been staring at it too long it's all now a blur. I have the following output generated and it's either:
Output1
====================================================================== +======== LDP Sessions ====================================================================== +======== Peer LDP Id Adj Type State Msg Sent Msg Recv Up Tim +e ---------------------------------------------------------------------- +-------- ---------------------------------------------------------------------- +-------- No Matching Entries Found ====================================================================== +========
OR
Output 2
====================================================================== +======== LDP IPv4 Sessions ====================================================================== +======== Peer LDP Id Adj Type State Msg Sent Msg Recv Up Tim +e ---------------------------------------------------------------------- +-------- 1.1.1.1:0 Targeted Established 822443 822431 273d 15:02:2 +0 ---------------------------------------------------------------------- +-------- No. of IPv4 Sessions: 1 ====================================================================== +========
I'm trying to match using the following code to trigger an IF statement. Basically I'm looking for if the output contains an IP address then stop, otherwise keep going. But, it seems my IF statement returns true even if nothing that looks like an IP address is returned. I've been on regex101 to test my matching and it checks out there, but must be something obvious!
if ( $output1 || $output2 =~ m/\d+\.\d+/gm ) { print "Found something"; exit; } else { print "Do this instead";
In reply to Regex match multiple line output by bartrad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |