我有以下脚本
print ("\n\n=========================================\n");
@array = (1,2,"Hello");
print("\$array[0] = $array[0]\n");
print("\$array[1] = $array[1]\n");
print("\$array[2] = $array[2]\n");
@array =(a..z);
**print("\@array[5..10]=@array(5,3..10,24");**
@lenght=@array;
print "The lenght of\@array is:@lenght\n";
print ("=========================================\n\n");.
标记为双**
,我没有得到预期的输出。请帮我解决这个问题。
我期望的输出就像这样的d,e,f,h,k
答案 0 :(得分:2)
如果您希望打印出特定的数组元素和整个数组的长度,请使用以下内容:
@array = ('a'..'z');
$newarray = @array[0,5..10];
print("\@array[0,5..10] = @array[0,5..10]\n");
$length = @array;
print "The length of \@array is $length\n";
输出是:
@array[0,5..10] = a f g h i j k
The length of @array is 26