| Author |
Message |
TN *nix forums beginner
Joined: 25 May 2005
Posts: 4
|
Posted: Thu Jul 20, 2006 9:07 am Post subject:
How to find out if a certain value is in a list?
|
|
|
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 |
|
| Back to top |
|
 |
anno4000@radom.zrz.tu-ber *nix forums beginner
Joined: 05 Jul 2006
Posts: 40
|
Posted: Thu Jul 20, 2006 9:21 am Post subject:
Re: How to find out if a certain value is in a list?
|
|
|
TN <tjpn@not_spam.surfeu.fi> wrote in comp.lang.perl.misc:
| Quote: | 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:
|
perldoc -f grep
Anno |
|
| Back to top |
|
 |
Tad McClellan *nix forums Guru
Joined: 09 Mar 2005
Posts: 1647
|
Posted: Thu Jul 20, 2006 11:49 am Post subject:
Re: How to find out if a certain value is in a list?
|
|
|
TN <tjpn@not_spam.surfeu.fi> wrote:
| Quote: | 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?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas |
|
| Back to top |
|
 |
TN *nix forums beginner
Joined: 25 May 2005
Posts: 4
|
Posted: Fri Jul 21, 2006 1:41 pm Post subject:
Re: How to find out if a certain value is in a list?
|
|
|
Great,
that gave me a good solution.
Thanks,
-TN
"Tad McClellan" <tadmc@augustmail.com> kirjoitti
viestissä:slrnebure8.drq.tadmc@magna.augustmail.com...
| Quote: | TN <tjpn@not_spam.surfeu.fi> wrote:
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?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas |
|
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|