How to find out if a certain value is in a list?

T

TN

Hi there,
what would be the shortest (or best...) way to find out if a certain value
is in the list like in the code here:

my @resultarray = &somefunc("case"); # returns a list (1,3,5,7,9) in this
case
# now I need to know whether 7 is in the @resultarray or not
if (...) {
# 7 was in the @resultarray
} else {
# 7 was not in the @resultarray
}


Greetings,
TN
 
T

Tad McClellan

TN said:
what would be the shortest (or best...) way to find out if a certain value
is in the list like in the code here:
^^^^
^^^^

perldoc -q list

How can I tell whether a certain element is contained in a list or
array?
 
T

TN

Great,
that gave me a good solution.
Thanks,
-TN

Tad McClellan said:
^^^^
^^^^

perldoc -q list

How can I tell whether a certain element is contained in a list or
array?
 
T

Tad McClellan

[ TOFU repaired ]


TN said:
Great,
that gave me a good solution.


Exactly so.

That is why good netiquette demands checking the FAQ before posting.



You're welcome.

Please see the Posting Guidelines that are posted here frequently.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top