in reply to Using regular expressions with arrays

You are getting warnings about uninitialized values because you are walking off the end of your arrays (I think). Am I correct in thinking you'd like to systematically check all Accession numbers against your GI list? To do that, you need to iterate over both lists, which in general means you need two loops - one for GI and one for Accession. If you also use last (assuming max 1 hit per target) to do some Loop Control, you might code something like:
for my $Accession (@Accession) { for my $GI (@GI) { if ($Accession =~ $GI) { print "$GI\n"; last; } } }
Note I've used the Foreach Loops construct instead of using an explicit index because you do not actually care for your output what the index was.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: Using regular expressions with arrays
by AnomalousMonk (Archbishop) on Apr 13, 2015 at 18:47 UTC

    Please see my reply to james28909 questioning the wisdom of depending on certain characters (separators) of the data to be regex metacharacters while ignoring the fact that others are also.


    Give a man a fish:  <%-(-(-(-<