my $cmd = "/usr/bin/nmap -sU -p 2300,6500 $ENV{'REMOTE_ADDR'}"; open NMAP, "$cmd|" or die $!; foreach () { # process here ... }