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 ( #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


Comment on Re: Array equality woes
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2014-09-24 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (246 votes), past polls