• Skip to content

Menu 1

  • Home
  • Work
  • Small Worlds
  • Play
  • Blog
  • Podcasts
  • Newsletter
  • About

Thomas
Beutel

Kinetic sculpture · prints · small worlds · stories
  • Home
  • Work
  • Small Worlds
  • Play
  • Blog
  • Podcasts
  • Newsletter
  • About
AuthorPostedbyThomason August 1, 2008

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.

♡

Posted in Perl, ProgrammingTagged typo perl error

1 Comment

  1. ~jess
    16 years ago Permalink

    You also get it with a typo like
    if ($item  =< $xray)
    instead of
    if ($item <= $xray)      # took me forever to find that one

Comments are closed.

Post navigation

Previous
Next
© 2026 Thomas Beutel Instagram · YouTube · SoundCloud
x