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

$a and $b are magic variables used by sort. Do not use them as general variables because your life will be unhappy (as you have found).

If you change $a to $aInt and $b to $bInt you get syntax errors rather than warnings. Because I've no idea what $b is supposed to be (it's not used anywhere else) I can't advise the best way of dealing with the problem. Probably you need to pass $aInt and $bInt into the sub.

Note, your problem could be demonstrated by:

#!/usr/bin/perl use strict; use warnings; $a->abs();

which sort of indicates that you didn't whittle the problem down very much.

Update: Humpf, I did consider that $a and $b were being provided by one of the used modules, then thought "Who in their right mind would lay traps like that". Hey ho. (See Re: Can't call method "abs" on an undefined value.)


DWIM is Perl's answer to Gödel