【发布时间】:2013-12-16 23:40:55
【问题描述】:
我有一个元素数组与 # 组合,我希望将其放入 hash 中,该数组的第一个元素作为键,在将该数组元素拆分为 # 之后作为值休息 但它没有发生。
例如:
my @arr = qw(9093#AT#BP 8111#BR 7456#VD#AP 7786#WS#ER 9431#BP ) #thousand of data
我想要的是
$hash{9093} = [AT,AP];
$hash{8111} = [BR]; and so on
我们如何使用地图功能来完成它。否则我需要使用 for 循环,但我希望使用 map 函数。
【问题讨论】:
-
您应该使用
use strict和use warnings运行您的Perl 代码。例如:Possible attempt to put comments in qw() list.