Hi Noosrep,

my $fct_openPort = (join ',',$fct_host_obj->tcp_ports('open'))."\n" ; my @fct_ports = split ',', $fct_openPort;

First of all, why first join the list of ports into a comma-separated string, only to split it back out again? Why not say for my $fct_port ($fct_host_obj->tcp_ports('open'))?

Second, note the ."\n": you're appending a newline to the end of the string, which remains there after the split. See the Basic debugging checklist, especially item 3 (unexpected whitespace)*. Remove the ."\n" and I suspect your code will work.

my @tcp_ports = qw/ 139 445 1984 /; my $fct_openPort = (join ',',@tcp_ports)."\n" ; my @fct_ports = split ',', $fct_openPort; use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper(\@tcp_ports,\@fct_ports); __END__ $VAR1 = [ 139, 445, 1984 ]; $VAR2 = [ 139, 445, "1984\n" ];

Also, you never tell us which module you're using? (I assume it's not relevant here, but you never know...)

* Update: You can already see the extra newline character in your output: "service and port = 1984 <newline> :"

Hope this helps,
-- Hauke D


In reply to Re: Last service name comes up empty in NMAP Parser by haukex
in thread Last service name comes up empty in NMAP Parser by Noosrep

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.