On Sep 7, 2004, at 3:15 AM, Edward WIJAYA wrote:

How can I take out/splice(?) the element of that hash
that start with '1' and store it into another
hash. So in the end I will have two hashes:

%myNEWhash = {  '1 NO MOTIF' => 'ATGGTTAGGG'};

and the current becomes:

%myhash = {
          '4 atc' => 'TGCGCatcGA',
          '5 ctg' => 'AGctgTGTTT',
          '3 NO MOTIF' => 'TCCGTGCGCT',
          '2 caa' => 'GAAGcaaGGC'
        };


foreach my $key(keys %myhash) {

    if($key =~ /^1 /) {

        $myNEWhash{$key} = $myhash{$key} ;

        delete $myhash{$key} ;

    }

}


HTH

Remo


-- 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