in reply to Re^2: Need Help with Maybe a Regex Issue
in thread Need Help with Maybe a Regex Issue

Here is a version which may help. You do not need the next LINE bit, and the C-style loop hides a bug - you never test for the last item in @tmpArray (BB_B06).
my @arrayOfVals; open(my $tmp, "<", "/Users/bioinformatics/Desktop/NC_001903.gff.txt") +or die "Could not open $!"; while (<$tmp>) { chomp; next if /^#/; # discard header, unneeded and will interfere push(@arrayOfVals, $_); } close($tmp); my %hashOfKeys; open (my $arrVal, "<", "/Users/bioinformatics/Desktop/cp26_dff.txt") o +r die "Could not open $!"; while (<$arrVal>) { chomp; $hashOfKeys{$_} = 1; } close($arrVal); my %hash; for my $k (0 .. $#arrayOfVals -1) { if ($arrayOfVals[$k] =~ /.*;locus_tag=(.*)/) { next unless $hashOfKeys{$1}; my $key = $1; if ($arrayOfVals[$k+1] =~ /.*;Name=(.*);protein_/) { $hash{$key} = $1; } } } print Dumper(\%hash);

Replies are listed 'Best First'.
Re^4: Need Help with Maybe a Regex Issue
by sharkbait (Initiate) on Mar 06, 2014 at 19:22 UTC

    I didn't see that, many thanks!