Ryszard has asked for the wisdom of the Perl Monks concerning the following question:

I've been hacking at a bit of code for a bit now and am pretty well (brain faded) stumped. I'm getting an "not an array reference at line <line>" error.

i'm getting the error when attempting to work out if one number is greater than another
1) print "email: ${$self->{_product}}->[0]{EMAIL} \n"; 2) print "total: (scalar(keys %{$self->{_alllogins}}))\n"; 3) if ( ${$self->{_product}}->[0]{EMAIL} > (scalar(keys %{$self->{_al +llogins}})) ) {
lines 1 and 2 (above) evaluate to 5, 7 respectivley.
The interesting bit is if i reverse the operator the error goes away, (but is not condition i am after).
i've even tried:
1) my $allowable = scalar( ${$self->{_product}}->[0]{EMAIL}); 2) my $current = (scalar(keys %{$self->{_alllogins}})); 3) if ($current ge $allowable) {
to no avail. I just cant work out why, when i reverse the condition, the error message goes away. I'm using 5.005_03. Someone please tell me i've got a wet fish problem here... :-)

.R

Replies are listed 'Best First'.
Re: problem with le and gt
by Ryszard (Priest) on Sep 13, 2001 at 10:29 UTC
    ok after just 5 seconds of looking at my code, a co-worker mentioned the problem was in the 'else' part of the code. yes i feel like an idiot.

    my problem was perl was reporting back the line number of the 'if' and the error was about 20 lines down in the 'else' part.

    /me chalks one up to experience.