Why doesn't Perl support interpolation of hashes in double quotes?

后端 未结 3 1245
不思量自难忘°
不思量自难忘° 2021-01-02 13:31
#!/usr/bin/perl
use warnings;

my %hash=(\"no1\"=>1, 
        \"no2\"=>2,
      );

print %hash; #Prints no11no22
print \"%hash\"; #Prints %hash
3条回答
  •  春和景丽
    2021-01-02 14:20

    How should a hash stringify? Scalars are obvious and arrays too. But what should a hash be? How useful will such a stringification be? Is it more or less useful than being able to use a % character unescaped in an interpolating string? Is it worth the amount of work it will take to fix all of the code that uses % in interpolated strings today?

    If you can come up with good answers to these questions, then I am sure P5P would be willing to listen to them.

提交回复
热议问题