Iva*_*ang 0 perl hash reference deprecated
sub function{
my $storedata=shift;
my $storenameandaddress=$storedata->{$storeid}->{name}
."_".$storedata->{$storeid}->{location}->{address}
."_".$storedata->{$storeid}->{location}->{city}
."_".$storedata->{$storeid}->{location}->{state}
."_".$storedata->{$storeid}->{location}{country};}
Run Code Online (Sandbox Code Playgroud)
我的代码如上所示.它给了我错误信息:
Using a hash as a reference is deprecated at main.pl line 141.
Run Code Online (Sandbox Code Playgroud)
但是,该功能仍然可以运行.所有的休息似乎都很好.那么这个错误在谈论什么?我该如何解决?谢谢.
您发布的代码没有给出警告.表格代码
%foo->{bar}
Run Code Online (Sandbox Code Playgroud)
发出警告.它给出了警告,因为它起到了作用
$foo->{bar}
Run Code Online (Sandbox Code Playgroud)
即使它不应该.
$ perl -wE'my %h = ( foo => 123 ); say %h->{foo};'
Using a hash as a reference is deprecated at -e line 1.
123
$ perl -Mdiagnostics -wE'my %h = ( foo => 123 ); say %h->{foo};'
Using a hash as a reference is deprecated at -e line 1 (#1)
(D deprecated) You tried to use a hash as a reference, as in
%foo->{"bar"} or %$ref->{"hello"}. Versions of perl <= 5.6.1
used to allow this syntax, but shouldn't have. It is now deprecated, and will
be removed in a future version.
123
$ perl -wE'my %h = ( foo => 123 ); say $h->{foo};'
123
Run Code Online (Sandbox Code Playgroud)