我正在運行以下簡單的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行是最後一條語句打印($ 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.
爲什麼我得到這個警告,我該如何解決?
奇怪的想法來關閉這個問題... – 2014-06-06 08:05:55