下
use strict;
use warnings;
my $foo = undef;
式
$foo . ''
と
"$foo"
両方が生成します
Use of uninitialized value $foo in ... at ...
しかし、次の式は警告なしに空の文字列を提供します。
$foo x 1
誰もが理由を知っていますか?つまり、素敵な文字列化のイディオム($_ x 1
よりもかなり短いdefined ? "$_" : ''
)があるのはクールですが、少し奇妙に感じます。