【发布时间】:2017-07-18 21:22:09
【问题描述】:
我有一个类似这样的代码:
foreach $item (@total_data)
{
setinfo($item);
} # @total_data contains an array of references to hashes (\%hash1 ... \%hashN)
在子程序中是这样的:
sub setinfo
{
my ($argument) = @_;
my $i = 0;
#inside original hash $argument{"data"}{"fulldraw"} there is an [array]
#that contains numbers of the form XYYZ and I want to split them into
#the following pairs XY YY YZ but that code works ok#
foreach $item (${$argument{"data"}{"fulldraw"}})
{
my $match;
my $matchedstr;
if ($item =~ /^\d{4}$/)
{
...
}
else
{
print STDERR "DISCARDED: $item\n";
}
}
}
我知道我在取消引用时可能犯了一个错误,但我无法通过我在互联网上阅读的所有文章来弄清楚。
谢谢!
【问题讨论】:
标签: perl multidimensional-array hash dereference