]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed compute
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 28 Oct 2008 07:31:47 +0000 (07:31 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 28 Oct 2008 07:31:47 +0000 (07:31 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@281 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/Biopieces.pm

index 0a0501a5e1e99054b85fb059460761556a70dbe0..a28473442c758907a98b2e790374baa42fb234a7 100644 (file)
@@ -5238,7 +5238,7 @@ sub script_compute
 
     # Returns nothing.
 
-    my ( $record, $eval_key, $eval_val );
+    my ( $record, $eval_key, @keys, $eval_val );
 
     while ( $record = get_record( $in ) ) 
     {
@@ -5248,11 +5248,22 @@ sub script_compute
             {
                 $eval_key = $1;
                 $eval_val = $2;
-            }
 
-            map { $eval_val =~ s/\Q$_\E/$record->{ $_ }/g } keys %{ $record };
+                if ( not @keys )
+                {
+                    @keys = split /\s+|\+|-|\*|\/|\*\*/, $eval_val;
+
+                    @keys = grep { exists $record->{ $_ } } @keys;
+                }
+
+                map { $eval_val =~ s/\Q$_\E/$record->{ $_ }/g } @keys;
 
-            $record->{ $eval_key } = eval "$eval_val" or Maasha::Common::error( "eval failed -> $@" );
+                $record->{ $eval_key } = eval "$eval_val" or Maasha::Common::error( "eval failed -> $@" );
+            }
+            else
+            {
+                warn qq(WARNING: Bad compute expression: "$options->{ 'eval' }"\n);
+            }
         } 
 
         put_record( $record, $out );