Re: Splicing Hash problem - possible with "map"?

2004-09-06 Thread Jeff 'japhy' Pinyan
On Sep 6, John W. Krahn said: >> map { $_, delete $myhash{$_} } grep /^1\D/, keys %myhash; > >Very good Gunnar! But the regexp may not work in all cases. > >my %myNEWhash = map { $_, delete $myhash{$_} } grep /^1(?:\D|$)/, keys %myhash; That regex can also be written as /^1(?!\d)/, which r

Re: Splicing Hash problem - possible with "map"?

2004-09-06 Thread John W. Krahn
Gunnar Hjalmarsson wrote: Edward WIJAYA wrote: Just thought whether it is possible to do it with "map" function? Make it into one-liner? It is. my %myNEWhash = map { $_, delete $myhash{$_} } grep /^1\D/, keys %myhash; Very good Gunnar! But the regexp may not work in all cases. my %myNEW

Re: Splicing Hash problem - possible with "map"?

2004-09-06 Thread Gunnar Hjalmarsson
Edward WIJAYA wrote: Just thought whether it is possible to do it with "map" function? Make it into one-liner? It is. my %myNEWhash = map { $_, delete $myhash{$_} } grep /^1\D/, keys %myhash; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [

Re: Splicing Hash problem - possible with "map"?

2004-09-06 Thread Edward WIJAYA
Hi, Thanks so much for the replies. If you literally mean "starts with '1'", i.e., you don't know any more about the key, Yes I literally mean "1" not "10", "100", etc. Just thought whether it is possible to do it with "map" function? Make it into one-liner? then first you must find the key, or us

RE: Splicing Hash problem

2004-09-06 Thread Thomas Bätzler
Edward WIJAYA <[EMAIL PROTECTED]> asked: > 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: Off the top of my head, I'd say my @temp = grep /^1/, keys %myhash; my %myNEWhash; foreach my $k (@temp)

Re: Splicing Hash problem

2004-09-06 Thread Peter Scott
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 >

Re: Splicing Hash problem

2004-09-06 Thread Remo Sanges
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' => '

Splicing Hash problem

2004-09-06 Thread Edward WIJAYA
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 th