Dear all, 

I would like to construct a hash, whose value holds a reference to an
array of arrays,
however all the keys in my hash have the exact same value, which turns
out to be the value of the last element I put it!!

I felt that something is wrong in the data structure, that I should not
keep re-using @match or @splice, they get overwritten, so I only came
with the last one. But I am not sure how to fix it, or is there a way?

Any insight is much appreciated!!!

-Jennifer 


#! /usr/bin/perl -w

my %hash;
my $MatchLine;
my $SVLine;

while (<STDIN>) {
  chomp $_;
  if (/^Query=(\w+)$/) {

    if ($key) {
    
    
    @match = split (' ', $MatchLine);
    @splice = split (' ', $SVLine);
    
    
    
    $ref = [\@match, \@splice];
    
    $hash{"$key"}= $ref;
    $key = $1;
    } else {
  
    $key =$1
    }
  } elsif (/^MA:(.+)$/) {
    $MatchLine = $1;
  } elsif (/^SV:(.+)$/) {
    $SVLine = $1;
  } else {
  }
}


foreach $key (keys %hash) {
        print "$key\n";
        print "$_" for (@$mref);
        print "\n";
        print "$_" for (@$svref);
        print "\n";
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to