Useless use of private variable in void context (Perl)
97
post-template-default,single,single-post,postid-97,single-format-standard,bridge-core-3.0.1,qodef-qi--no-touch,qi-addons-for-elementor-1.5.3,qode-page-transition-enabled,ajax_updown,page_not_loaded,,vertical_menu_enabled,side_area_uncovered_from_content,qode-theme-ver-28.7,qode-theme-bridge,disabled_footer_top,qode_header_in_grid,wpb-js-composer js-comp-ver-6.8.0,vc_responsive,elementor-default,elementor-kit-6

Useless use of private variable in void context (Perl)

Useless use of private variable in void context (Perl)

Can you see what is wrong with this Perl code snippet?

foreach my $cat (@$categories) {
if ($cat->{col} == $column and $cat=>{pos} == $position) {
return $cat;
}
}

It gets the “Useless use of private variable in void context” at the last brace. Well, it took me a while, but it was the equal sign in $cat=>{pos} which should be $cat->{pos}. Worse, I copied and pasted this code somewhere else, which doubled the problem. (Yes I know, all copying and pasting is evil–I get it!)

In any case, this comment on Perlmonks was helpful, suggesting to look for typos backward from the point of the error. Yup, that’s exactly what it was.



Mastodon