in reply to Need a replacement method for older version of perl

Using first might not be a great idea. If $curEntry is the empty string "", and @taxR does actually contain an empty string (so you should expect a match), then first will end up returning false.

The any function from List::MoreUtils is probably a better choice.

As to your question, you might get better performance from a hash:

my @taxR = ("PLRV1", "PMTVS", "PVXHB"); # Copy the array into a hash. # Make sure you only do this once. my %taxR = map {$_ => 1} @taxR; my $curEntry = "PMTVS"; if (exists $taxR{$curEntry}) { print "do rest of stuff"; }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Need a replacement method for older version of perl
by vivomancer (Initiate) on Jun 26, 2012 at 23:30 UTC
    Thank you, that's much more logical that what I was doing. Though it turns out that wasn't what was causing my program to break. I'm going to make a new thread since its going to be different enough from my topic title