#!/usr/bin/perl use strict; use warnings; use Regexp::Common qw/ net /; my $output = "ae4.5784 up down inet 182.75.123.121/30"; if ( $output =~ m/$RE{net}{IPv4}/ ){ print "match!\n" } __END__ $ perl test.pl match!