in reply to Re^3: The most efficient way for searching for an element in an array?
in thread The most efficient way for searching for an element in an array?
my @arr = qw(Apple Banana Tiger Lion Cat Turtle); my $arr = join("|", @arr); my $flag1 = ($arr =~ m/Apple|Turtle/) ? 1 : 0;
That breaks as soon as the elements of @arr may contain the string used to join the arrays. Also, it roughly doubles the memory usage. Imagine a 2 GByte @arr on a machine with 4 GByte RAM.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |