Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Evaluating Multidimensional Arrays and References

by bikeNomad (Priest)
on Aug 10, 2001 at 19:48 UTC ( #103919=note: print w/ replies, xml ) Need Help??


in reply to Evaluating Multidimensional Arrays and References

The problem is that the @{...} returns an array. When you compare this with "John", it gets converted into a scalar, which is the size of the array (probably 1 in this case). So you're saying 'if 1 eq "John"'...

The reason that it prints is that its contents are being interpolated into the string (separated by $, but that doesn't matter if you have one element).

What you probably want is to say:

if ($self->{_mydata}[2][3][0] eq "John") { print "My name is $self->{_mydata}[2][3][0]\n"; }


Comment on Re: Evaluating Multidimensional Arrays and References
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2015-07-08 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls