in reply to port scanner using nmap
No need to shell out... there's an API for that!
I haven't tried that one, but I've helped work on an older one: Nmap::Parser, which also can run a scan directly with the parsescan method.