Skip to main content


Basically, my Perl code wants to achieve the following :

my @array = qx{cat /some/servers/list}; # this is working

my $port = 30004;

foreach(@array) {

my $return_code = system ("/usr/bin/nc -zv", $_, $port) # wanting to run nc -zv hostname 30004

But it just isn't working.

What I've tried so far :

  1. foreach(@array) {

my @ args = ($_." ".$port)

my $return_code = system ("/usr/bin/nc -zv", @ args)

  1. Used IPC::System::Simple qx/systemx/ and then passed the whole thing thru systemx instead of system
  2. Used qx, Used exec, doesn't work.

Note: I need the return code for rest of dependant logic down the road, so have to have the $return_code scalar.

Please help! I'm at my wits end!

submitted by /u/icy-mist-01
[link] [comments]