in reply to Regex match multiple line output

You must check each one. Your result is always 'true' because $output1 is always 'true'.

UPDATE: Consider using Regexp::Common::net to test for IP's.

if ( $output1 =~ m/\d+\.\d+/m or $output2 =~ m/\d+\.\d+/m ) {

Your use of /g is inappropriate.

Bill

Replies are listed 'Best First'.
Re^2: Regex match multiple line output
by bartrad (Beadle) on Feb 20, 2018 at 15:55 UTC

    Damn... back to the reading books... Thank you.

      bartrad: You are well advised to use Regexp::Common::net for IP matching, but be aware that by design, these regexes are not "bounded" or "delimited"; used as-is, they may match things you don't consider a proper IP and you may need to define your own regex. In the case of the  $RE{net}{IPv4} dotted-decimal IP matcher, consider:

      c:\@Work\Perl\monks>perl -wMstrict -le "use Regexp::Common qw(net); ;; my $s = '123456.4.32.123456'; ;; print qq{A: match, captured '$1'} if $s =~ m{ ($RE{net}{IPv4}) }xms; ;; my $my_ip = qr{ \b $RE{net}{IPv4} \b }xms; print qq{B: match, captured '$1'} if $s =~ m{ ($my_ip) }xms; " A: match, captured '56.4.32.123'


      Give a man a fish:  <%-{-{-{-<