How do I parse multi-line output to a system command? For example, I have a list of system names I want to get the IP address using ‘nslookup’. When I use this approach the print statement prints all 5 lines of the nslookup command. It seems no matter how I reference $totalArray I always get all 5 lines of output.
my $totalArray = system ( "nslookup", "$nodeName"); my @totalArraySplit = split(":", $totalArray); print STDOUT ("$totalArraySplit[1]\n");
How do I capture the multi-line output and split it into separate lines I can reference or into a multi-dimensional array?
In reply to capturing and parsing multiline output by ScooterTrash
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |