我是Perl新手,需要一些幫助調試。 這裏是我當前的代碼(在底部的數據線絕密隱私):Perl對單值化的使用
use strict;
use warnings;
use Email::Address;
my %matches;
my $records = 0;
my $recipient = "";
while (<DATA>) {
foreach my $addr (Email::Address->parse($_)) {
my @fields = split /\s/, $_;
$records = $fields[12];
$recipient = $addr->address;
$matches{'$recipient'} += $records;
}
}
foreach my $rfc822 (keys %matches) {
print $matches{'$rfc822'}, " ", $rfc822, "\n";
}
__DATA__
這是我收到的錯誤:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\redacted>C:\Perl\test4.pl
Use of uninitialized value in print at C:\Perl\test4.pl line 18, <DATA> line 4.
$recipient
任何幫助,因爲我一直停留在大加讚賞這幾天,謝謝!
變量不會在單引號內插,我相信你的意思'$比賽{ 「$ RFC822」}'。然而,由於'$ rfc822'是一個變量,所以您可以完全忽略引號:'$ matches {$ rfc822}' –
如果您需要隱藏帖子中的敏感信息,那麼最好用代替產生相同問題的想法替代。你讓我們更容易地重現你遇到的問題,你會得到更好的質量答案。 – Borodin