
bossanova352
New User
Mar 14, 2013, 8:26 PM
Post #1 of 4
(136 views)
|
|
Searching hash for values that make part of a key
|
Can't Post
|
|
Hi all, I'm trying to search through a hash for numbers that correspond to the last few numbers in each string in the keys. The keys look something like this (yes it's a fasta): >ID_#_length_#_cov_# I want to filter by the cov_#, and I've gotten so far as to separate these cov_#'s out and can filter them alone. However, I'd like to search through the keys in the hash for the cov_#'s and print out both the keys and values that are left over after filtering the cov_#'s. Here is what I have so far (%sequences is the hash that already has appropriate keys and values):
foreach $header (%sequences){ $header =~ /cov_([0-9]*\.[0-9]*)/; $cov = $1 * 1.0; if ($cov <= 50 && $cov >= 5){ #print $cov, "\n"; } } Any help would be greatly appreciated!
|