in reply to Assigning output of unix command to a variable

Not really sure why it doesn't get past the '|' (works fine here), but what looks suspicious is the @nodes=(<LIST>); as this reads everything from the second line onwards into an array which you never use in the loop. As a result, there would only be one call to nslookup with $_ holding the first line of the input file. Not sure if that's intended.

Independently of that, you probably want to escape the $2 in the awk command, because backticks do interpolate variables... i.e.

my $nodename=`nslookup $_ | awk -F Name: '{ print \$2 }'`;

Replies are listed 'Best First'.
Re^2: Assigning output of unix command to a variable
by ksermas (Initiate) on Sep 04, 2012 at 18:53 UTC
    Thank you very much. You were right. As soon as I eacaped the '$' it worked perfectly!!!