UndergroundVault UndergroundVault - 1 year ago 210
Perl Question

Perl "keys on reference is experimental" warning

My perl program is throwing some warnings, and I am yet to have any luck searching the Internet for a solution. Is there any way I can rewrite the following code snippet so that no warnings are thrown?

"keys on reference is experimental at...":

foreach my $key ( keys %$api_decoded_result{'query'}->{'pages'} ) {
@words = split / /, $api_decoded_result->{'query'}->{'pages'}{$key}->{'extract'};

Answer Source

Yup. This is because of precedence of operator dereferencing. %$api_decoded_result binds tighter than the {'query'}.

keys %{$api_decoded_result{'query'}->{'pages'}}

Will do what you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download