Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Array equality woes

by MarkM (Curate)
on Oct 12, 2003 at 15:16 UTC ( [id://298658]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://298658]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-20 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found