请看下面两段PERL程序
仅仅KEYS不同,而结果不同。
#! /usr/bin/perl
%array1=(1,"111",2,"222",3,"333",4,"444",5,"555",6,"666" ;
@array2=values(%array1);
print("%array1:" ;
print($array1{1}," ",$array1{2}," ",$array1{3},"\n" ;
# print("@array2:" ;
print ($array2[0]," ",$array2[1]," ",$array2[2]," ",$array2[3],"\n" ;
的结果是:%array1:111,222,333
111,222,333,444
#! /usr/bin/perl
%array1=(one,"111",two,"222",three,"333",four,"444",five,"555",six,"666" ;
@array2=values(%array1);
print("%array1:" ;
print($array1{one}," ",$array1{two}," ",$array1{three},"\n" ;
# print("@array2:" ;
print ($array2[0]," ",$array2[1]," ",$array2[2]," ",$array2[3],"\n" ;
的结果是:%array1:111,222,333
111,555,333,222
请指教!WHY! |