Use of uninitialized value in concatenation (.) or string atというエラー

  1 #!/usr/bin/perl
  2 
  3 use warnings;
  4 use strict;
  5 
  6 my $hello;
  7 print "$hello\n";


このプログラムを実行すると、以下のようなエラーメッセージが出力されます。

Use of uninitialized value in concatenation (.) or string at ./hello.pl line 7.


問題は変数$helloを初期化することもなく、何の値も格納することもなく、使っているからです。
よって、以下のようにするとエラーメッセージは出力されません。

  1 #!/usr/bin/perl
  2 
  3 use warnings;
  4 use strict;
  5 
  6 my $hello = '';
  7 print "$hello\n";