Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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 '.'


"@{$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 '.' ...


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://298658]
[LanX]: moritz, no ... jsut copy one line of my code
[moritz]: I'm still using the CB, because ambrus's #cbstream makes it bearable
[LanX]: ... the rest is loaded from a node
[holli]: the best course of action would be to transfer the data to something well tested. even if it isnt perl based
[moritz]: but even if I had all the time in the world, I wouldn't spend much on perlmonks
[LanX]: holli: LOL
[LanX]: moritz: why ? family?
[LanX]: or other language?
[moritz]: LanX because of usability issues, and the lack of evolvement
[holli]: lol to the robust charme or to the data transfer?

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2017-11-20 19:24 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.