Off topic:perl programming error
1
0
Entering edit mode
7.3 years ago

hi everyone,

I am trying to make a program in which I am making a subroutine and passing(returning) its values into a array and then printing it. Actually the values which are being passed are read by an scalar variable what I am not able to do is to store it in an array afterwards or maybe something else.

the program is as follows-

@a=data2();
print " the array is @a \n";
division(@a);
sub division(@a){
($tcount)=@a;
print "in division array is first $tcount \n";
  }
sub data2(){
   open (FH,"dataset2.txt");
   %seq_dt2=<FH>;
   @index2=keys%seq_dt2;
   print "@index2";
   $len2=@index2;
   print "$len2";
 $occ_f_6len_in_1000bp_seqfile=995;
 $total_occurance= ($occ_f_6len_in_1000bp_seqfile * $len2)/6;
 print "ref ka occurance h ye $total_occurance";
 @seq2=values%seq_dt2;
 chomp (@seq2);
  print "@seq2";
  open (FILE,"Motif6.txt");
   @motif=<FILE>;
   chomp @motif ;
    print " @motif\n";
   foreach $motif (@motif) {
   foreach $seq2 (@seq2) {
   if ($seq2 =~ /$motif/) {
   $tcount++;
   }
  }
 print "$motif $tcount \n";
 print " $tcount \n";
  return ("$tcount");
  $tcount =0;
   close (FH);
    }

my dataset2 file is -

  >1
  ATGCATAAAAAAATCGACTAGCTACGATCGATCAGAAAAACACAC
  >2
  CAGCTAAAAAGCTACGAAAAAAATCGATAGCTAGAAAAACA

my motif6 file is-

  AAAAAA
  AAAAAT
  AAAAAG
  AAAAAC

the output which m getting is -

the array is 2
in division array is first 2

the desired output which i want is-

   the array is 2,2,1,2
   in division array is first 2,2,1,2
  AAAAAA   2
  AAAAAT   2
  AAAAAG   1
  AAAAAC   2
perl programming perl error • 1.2k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2512 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6