http://www.perlmonks.org?node_id=298658


in reply to Array equality woes

The use of the 'eq' operator, or the '=~', will force the lvalue into scalar context. Your array, as a scalar, is interpretted to be the length of the array at the time of reference. You are comparing "1" to ".".

You likely intend one of the following:

@{$Circ->[$i][$j]} == 1 && $Circ->[$i][$j][0] eq '.'

or,

"@{$Circ->[$i][$j]}" eq '.'

Note, in the latter case, that the array is being interpolated within a string. This code is equivalent to:

join($,, @{$Circ->[$i][$j]}) eq '.'

For simplicitly, I would choose to use a temporary variable:

my $cell = $Circ->[$i][$j]; ... @$cell == 0 && $cell->[0] eq '.' ...

Cheers,
mark