简体   繁体   English

如何将长度打印到文本框中的指定输入

[英]How to print the length to specified input in the text box

as i need to print according to the difference of the length (693 to 712) as like mentioned in all line of sequences.if i entered length as 20 it should print only the sequence which differs 20 and if i enter text box value as 20 and dropdown selection is greater than it should print the length of seuences which matches greater than twenty. 因为我需要根据长度的差异(693至712)进行打印,就像在所有序列行中提到的那样。如果我输入长度为20,则应该只打印相差20的序列,如果我输入文本框值为20下拉选择大于它应打印的匹配长度大于20的序列的长度。

example.txt example.txt

GGATCACGAGGTCAGGAGAT (693 TO 712)   ATCTCCTGACCTCGTGATCC (3223 TO 3242)
CAAAAAAAAAAAAAAAAAAA (917 TO 936)   TTTTTTTTTTTTTTTTTTTG (2998 TO 3017)
GAAACCCCGTCTCTACTAAAAATACAAAAAA (737 TO 767)    TTTTTTGTATTTTTAGTAGAGACGGGGTTTC (3168 TO 3198)

perl 佩尔

#!usr/local/bin/perl
open(IN,"/home/httpd/cgi-bin/r/example.txt")|| die("Cannot open file");
while(<IN>)
{
    if($_ =~ /^\w+\s+\((\d+)\s+[to]+\s+(\d+)\)/i )
    {
        $data=$_;

        $num1=$1;
        $num2=$2;
        $diff=($num2-$num1)+1;
        $str="a".$diff;
        #print $str;
        push(@$str,$data);
    }
}

I don't know how you are capturing value from client side, why you are concatenating "a" with $diff and adding 1 in $diff , but it will work well if provided values from the command line. 我不知道您是如何从客户端获取价值的,为什么要用$diff连接"a"并在$diff添加1,但是如果从命令行提供值,它将很好地工作。

The values are stored in hash instead of array. 这些值存储在哈希中,而不是数组中。

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

open my $fh, '<', 'example.txt' or die "unable to open file: $!";
my %hash;
while(<$fh>){
my @seq=split(/\)\s+/,$_);
foreach(@seq)
   {
$_=$_.") ";
#print $_;
if($_ =~ /(\d+)\s*TO\s*(\d+)/i ){
       my $num1=$1;
       my  $num2=$2;
my $diff=($num2-$num1)+1;
$hash{$_}=$diff;

  }
}
}
close($fh);
#print Dumper(\%hash);
print "enter the number: \n";
chomp(my $num=<>);
if($num == 20){
foreach(keys %hash){
print "$_ => $hash{$_} \n" if($hash{$_} == 20);
}
}
elsif($num > 20){
foreach(keys %hash){
print "$_ => $hash{$_} \n" if($hash{$_} >  20);
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM