Well, with much help I have ben able to come up with this currently not working code:

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

my(%gap, %gap_pos, $animal);

while (<DATA>) {
  if (/>(\w+)/) {
    $animal = $1;
  } else {
    while (/(-+)/g) {
      my $gap_length = length $1;
      my $position = pos ($1);
      $gap{$animal}{$gap_length}++;
      push (@{$gap{$animal}{$gap_length}}, $position);
      }
  }
}

print Dumper \%gap;

__DATA__
>human
acgtt---cgatacg---acgact-----t
>chimp
acgtacgatac---actgca---ac
>mouse
acgata---acgatcg----acgt

Actually, the code will work fine if you remark the second and last lines of the inner while loop. Anyway, I am having trouble adding position data to my Hashes. I would like Data Dumper to output data like this (I always get my syntax messed up so I will just show part of $VAR1, but hopefully, you'll understand):

$VAR1 = {
          'human' => {
                       '5' => '1' =>      {
                                                25
                                        }
                       '3' => '2'     =>  {
                                                6,
                                                16,
                     },
}

So, I am trying to figure out why the code I have does not work? What am I "not getting"? Any suggestions?

-Thanks
-Mike


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to