A hash is handy for these type of jobs.
#!/usr/bin/perl use strict; use warnings; my @array = (qw(peter paul john mary)); my $name = 'jim'; my %lookup = map { $_ => undef} @array; die "$name not found\n" unless exists $lookup{$name}; print "found $name\n";
In reply to Re: searching an array
by wfsp
in thread searching an array
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |