我正在运行以下简单的 Perl 程序。
use warnings;
use strict;
my %a = (b => "B", c => "C");
print "Enter b or c: ";
my $input = <STDIN>;
print "The letter you just entered is: ", $input, "\n";
my $d = $a{$input};
print ($d);
当我输入 b 时,我得到了以下带有警告的输出。第 47 行是最后一条语句 print ($d);
Enter b or c: b
The letter you just entered is: b
Use of uninitialized value $d in print at C:/Users/lzhang/workspace/Perl5byexample/exer5_3.pl line 47, <STDIN> line 1.
为什么我会收到此警告,我该如何解决?