my @matches = grep {defined $_} map { /^($subnet\.\d+)/ and $1; } @lines;