For eg, I want to store the contents of the command ipconfig
in an array, such that each line of output is stored in a new index of array, i.e.
array[0]
contains the 1st line output.
array[1]
contains the 2nd line output and so on.
How can I achieve that?
答案 0 :(得分:9)
一个简单的
@array = `ipconfig`;
诀窍。请注意,正如Borodin正确指出的那样,所分配的数组元素包括换行符。