in reply to Section of $string into new array

This may be something like what you want. It's usually best for maintainability and comprehensibility to build up complex regexes from simpler components. And then there's also Regexp::Common (see esp. Regexp::Common::net).

c:\@Work\Perl\monks>perl -wMstrict -le "my $octet = qr{ 25 [0-5] | 2 [0-4] \d | [01]? \d [0-9]? }xms; my $ip = qr{ (?<! \d) $octet (?: \. $octet){3} (?! \d) }xms; my $addr = qr{ $ip / \d{1,2} (?! \d) }xms; ;; my $s = 'x 0.0.0.0/0 y 1.23.234.1/1 z 255.25.2.2/99 ' . '9999.9.9.999/1 z 9.9.9.9/999' ; ;; my @addrs = $s =~ m{ $addr }xmsg; printf qq{'$_' } for @addrs; print ''; ;; ;; use Regexp::Common qw(net); ;; my @common = $s =~ m{ (?<! \d) $RE{net}{IPv4} / \d{1,2} (?! \d) }xmsg +; printf qq{'$_' } for @common; " '0.0.0.0/0' '1.23.234.1/1' '255.25.2.2/99' '0.0.0.0/0' '1.23.234.1/1' '255.25.2.2/99'

Update: Added Regexp::Common::net example.