in reply to Re: Can't call method "abs" on an undefined value.
in thread Can't call method "abs" on an undefined value.

Ah ha! I knew it was something simple I was missing. Thanks that gives me enough to take a stab at it again.

reduce is included on the import list for List::Util in the main program I just forgot it in my sample. Adding it still gives the warning about $a and $b only being used once. I've updated the sample and my post.

Owl looked at him, and wondered whether to push him off the tree; but, feeling that he could always do it afterwards, he tried once more to find out what they were talking about.

  • Comment on Re^2: Can't call method "abs" on an undefined value.

Replies are listed 'Best First'.
Re^3: Can't call method "abs" on an undefined value.
by ikegami (Patriarch) on May 05, 2006 at 23:30 UTC

    In this case, the warnings are wrong. Those variables *are* used more than once, but List::Util sets them in a fashion that Perl can't detect at compile-time. (Something like *{caller() . '::a' = ...;.) You can get rid of the warnings by including the following in your package:

    $a = $a; $b = $b;

    Ignore the warnings when trying to find your error, they are misleading you. (But do change the variable name in my $a = ...; to something else!)

      Thanks! That took care of the warnings.

      Owl looked at him, and wondered whether to push him off the tree; but, feeling that he could always do it afterwards, he tried once more to find out what they were talking about.