I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2008-11-07 18:49:55-08 by someguy
Output format syntax
I'm having a little difficulty with formatting some output. I'm new to perl, so maybe there is a simple fix. My script contains the following code snipet:
$np->callback ( \&yeeha ); $np->parsefile($xml_file); sub yeeha { my $host = shift; #Nmap::Parser::Host object, just parsed print $host->addr,":",$host->tcp_ports('open'),"\n"; }
which returns something like this:
192.168.1.2:251351394452105

and I'd like to to look like this:
192.168.1.2:25
192.168.1.2:135
192.168.1.2:139
192.168.1.2:445
192.168.1.2:2105

Anybody have any ideas how I can produce this output? If I can't get to this output directly I wouldn't even mind if I had to go through a few steps (bash or otherwise). Thanks to anyone who can help!
Direct Responses: 9274 | Write a response
Posted on 2008-11-10 13:48:06-08 by dossy in response to 9257
Re: Output format syntax
According to the Nmap::Parser documentation, Nmap::Parser::Host's tcp_ports() method returns a sorted list of ports. See:

http://search.cpan.org/dist/Nmap-Parser/Parser.pm#Nmap::Parser::Host

Replace this line:

print $host->addr,":",$host->tcp_ports('open'),"\n";

with this:

printf("%s:%s\n", $host->addr, $_) for ($host->tcp_ports('open'));
Direct Responses: Write a response