X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fgrab;h=85063dec0234c82d30e481b15948fd55fc47ef37;hb=6fcdc25f807208008caff07608be15671809aa42;hp=806ae1c10d2ad70c5a2708efce01f783e5dc14eb;hpb=66938be910a5642b50ddf28991649858b5c36580;p=biopieces.git diff --git a/bp_bin/grab b/bp_bin/grab index 806ae1c..85063de 100755 --- a/bp_bin/grab +++ b/bp_bin/grab @@ -1,4 +1,4 @@ -#!/usr/bin/env perl -w +#!/usr/bin/env perl # Copyright (C) 2007-2009 Martin A. Hansen. @@ -26,7 +26,9 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +use warnings; use strict; +use Data::Dumper; use Maasha::Biopieces; use Maasha::Common; use Maasha::Patscan; @@ -180,13 +182,17 @@ sub grab_patterns # Returns boolean. - my ( $pattern ); + my ( $pattern, $key ); foreach $pattern ( @{ $patterns } ) { if ( $keys ) { - map { return 1 if index( $record->{ $_ }, $pattern ) >= 0 } @{ $keys }; + foreach $key ( @{ $keys } ) + { + return 0 if not exists $record->{ $key }; + return 1 if index( $record->{ $key }, $pattern ) >= 0; + } } else { @@ -222,7 +228,7 @@ sub grab_regex if ( $keys ) { - map { return 1 if $record->{ $_ } =~ /$regex/ } @{ $keys }; + map { return 1 if exists $record->{ $_ } and $record->{ $_ } =~ /$regex/ } @{ $keys }; } else {