$svcDesc = $htmlStream->get_phrase('/td'); $svcDesc =~ s/\n/,/g; push @svcPorts, "$1:$2" while ($svcDesc =~ /Protocol:\s(TCP|UDP).+?Destination\sPort:\s([0-9\-]+)/g); s/:(\d+)\-\1/:$1/ for (@svcPorts);