in reply to Text formatting a command in CGI

As mentioned, system doesn't return the output of the program you run (only its return code). You got lucky with that line of your program: whatever you execute via system shares STDOUT with your script, so the output of nmap happened to get printed to the web page at the right time (only not via your print statement).

You are on the right track using multi-arg system for safety. If you want to get data back from the call, you can use a magic open call. It's safer than using backticks (see above).

open(my $fh, '-|', 'nmap', $ip); ## may not be supported in your version of Perl, so ## also consider the equivalent: ## open(my $fh, '-|') or exec 'nmap', $ip; my $data = do { local $/; <$fh> }; close $fh;
Now you can do what you like with what's in $data -- replace newlines with <br>'s, print between <pre> tags, etc.

Update: BTW, the <pre> HTML tag makes the browser wrap according to your whitespace (instead of ignoring whitespace), as in my example code snippet. Search for it at your favorite HTML reference site and you will see what I mean.

Update II:Heh. Yeah, using text/plain will work too. But if you ever want to do anything with the data, get it from the program with the magic open call.

blokhead