错误:引用上的键的参数类型必须是不可用的

时间:2018-05-10 16:01:22

标签: perl

我收到错误

  

引用键的参数类型必须是xxxx.pl第6518行的非散列hasref或arrayref

部分脚本是

    ndr_log("Processing file: $file [$filesize bytes] Portion: $portion; Billing Date/MDate: $portion_date/$filemtime; Reading Proc: [$entries/$entries_reading/$entries_n15]: $reading_proc", 'Info');

    if (!defined $BILL->{$portion}->{$portion_date}->{mtime}
            or $BILL->{$portion}->{$portion_date}->{mtime} < $filemtime) {

        $BILL->{$portion}->{$portion_date}->{mtime}    = $filemtime;
        $BILL->{$portion}->{$portion_date}->{entries}  = $entries;
        $BILL->{$portion}->{$portion_date}->{readings} = $entries_reading;
        $BILL->{$portion}->{$portion_date}->{n15}      = $entries_n15;
        $BILL->{$portion}->{$portion_date}->{proc}     = $reading_proc;
        $BILL->{$portion}->{$portion_date}->{ok}       = $meter_ok;
        $BILL->{$portion}->{$portion_date}->{nok}      = $meter_nok;
    }
    else {
        DbgPlain("Ignoring file: $file; this is older result; never version exists: $BILL->{$portion}->{$portion_date}->{mtime}");
    }

} # for files

# Create Report
#
my @REPORT;

for (sort keys $BILL) {  ### Line 6518

    my $portion = $_;

    for ( sort keys $BILL->{$portion} ) {

        my $portion_date = $_;

        #ndr_log("Portion: $portion on $portion_date")

        my $entries         = $BILL->{$portion}->{$portion_date}->{entries};
        my $entries_reading = $BILL->{$portion}->{$portion_date}->{readings};
        my $entries_n15     = $BILL->{$portion}->{$portion_date}->{n15};
        my $reading_proc    = $BILL->{$portion}->{$portion_date}->{proc};
        my $meter_ok        = $BILL->{$portion}->{$portion_date}->{ok};
        my $meter_nok       = $BILL->{$portion}->{$portion_date}->{nok};

无论如何要解决它?

我的新服务器ActivePerl 5.16.3 build 1604和Build 1603版本。是否是版本问题?

1 个答案:

答案 0 :(得分:0)

**Line 1618:**  for (sort keys $BILL) {

$BILL是一个标量值(以$开头),特别是对哈希的引用,可以看出它之前是如何使用的。您需要在哈希本身上调用keys而不是对它的引用。要执行此操作,您需要取消引用它以获取哈希并在其上调用keys,即使用keys %$BILL而不是keys $BILL