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
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
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: [
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
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)
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
>
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' => '
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