#!/usr/bin/perl
#!/usr/bin/perl
%data = ('google'=>'google.com', 'runoob'=>'runoob.com', 'taobao'=>'taobao.com');
@names = keys %data;#该函数返回所有哈希的所有key的数组
#注意是数组
print "$names[0]\n";
print "$names[1]\n";
print "$names[2]\n";
%data2 = ('google'=>'google.com', 'runoob'=>'runoob.com', 'taobao'=>'taobao.com');
@urls = values %data2;#该函数返回所有哈希的所有value的数组
#注意是数组
print "$urls[0]\n";
print "$urls[1]\n";
print "$urls[2]\n";
来源:博客园
作者:朵朵奇fa
链接:https://www.cnblogs.com/shunguo/p/11441667.html