use warnings; use strict; use Regexp::Common qw/net/; my $output = "ae4.5784 up down inet 182.75.123.121/30"; if ( $output =~ /\b$RE{net}{IPv4}\b/ ) { print "There IS an IPAddress in the output string\n"; } else { print "There is NO IPAddress in the output string\n"; }