You can run an nmap scan and have the parser parse the information automagically. The only thing is that you cannot use '-oX', '-oN', or '-oG' as one of your arguments for the nmap command line options passed to parsescan().
CPAN::Forum
Nmap-Parser - Automagically parsing an nmap scan with Nmap-Parser