if( $hsp->length('total') > 1000 ) { if ( $hsp->percent_identity >= 90 ) { if( $hsp->score ){ if( $hsp->gaps ){ if( $hsp->expect ){ print "Hit= ", $hit->name, " Length=", $hsp->length('total'), " Score=", $hsp->score,"\n"; print "Gaps=", $hsp->gaps, " Expect=", $hsp->expect, " Percent_id=", $hsp->percent_identity, "\n"; my $aln = $hsp->get_aln; my $alnIO = Bio::AlignIO->new(-format =>"clustalw", -file => $out); $alnIO->write_aln($aln); } } } } } ## better is to reduce the levels of "if" by using "and" or && if ( ($hsp->length('total') > 1000 ) && ($hsp->percent_identity >= 90 ) && ($hsp->score ) && ($hsp->gaps) && ($hsp->expect) ) { #do your print stuff }