#!/usr/bin/perl use strict; use warnings; use Regexp::Common qw(net); use String::Util qw(trim); while (<>) { /$RE{net}{IPv4}{-keep}/ and printf "%s\n", trim($1); /$RE{net}{IPv6}{-sep => ':'}{-style => 'HeX'}{-keep}/ and printf "%s\n", trim($1); /$RE{net}{MAC}{-keep}/ and printf "%s\n", trim($1); }