In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Edward WIJAYA) writes:
>Hi,
>
>If I have this hash:
>
>%myhash = {
> '4 atc' => 'TGCGCatcGA',
> '5 ctg' => 'AGctgTGTTT',
> '3 NO MOTIF' => 'TCCGTGCGCT',
> '1 NO MOTIF' => 'ATGGTTAGGG', #need to splice this
> '2 caa' => 'GAAGcaaGGC'
> };
>
>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'
> };
my %myNEWhash;
$myNEWhash{"1 NO MOTIF"} = delete $myhash{"1 NO MOTIF"};
If you literally mean "starts with '1'", i.e., you don't know
any more about the key, then first you must find the key, or
use, say, Tie::Has::Regex from CPAN.
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>