Re: solution for Regex

2011-06-11 Thread John Delacour
At 08:28 -0700 10/06/2011, Gurpreet Singh wrote: Correct me if i am wrong - $read = 0 unless /\s[A-Z]{3}:/; This might pick up wrong values also - since one of the DBLINKS data (the first record) might also get picked up - it should match this regex. Run my script with the data and see. $r

Re: solution for Regex

2011-06-10 Thread Gurpreet Singh
Hi, Correct me if i am wrong - $read = 0 unless /\s[A-Z]{3}:/; This might pick up wrong values also - since one of the DBLINKS data (the first record) might also get picked up - it should match this regex. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-ma

Re: solution for Regex

2011-06-10 Thread Uri Guttman
> "JD" == John Delacour writes: JD> At 18:50 -0400 09/06/2011, Uri Guttman wrote: >> ...i don't know the data logic so i can't go further. at least you >> can run this and assign it to $read to remove redundancy. also you >> can declare $read here. >> >> my $read = s/^GENES//;

Re: solution for Regex

2011-06-10 Thread John Delacour
At 18:50 -0400 09/06/2011, Uri Guttman wrote: ...i don't know the data logic so i can't go further. at least you can run this and assign it to $read to remove redundancy. also you can declare $read here. my $read = s/^GENES//; No it isn't. If you don't "know the data logic" then i

Re: solution for Regex

2011-06-09 Thread Uri Guttman
> "JD" == John Delacour writes: JD> use strict; use warnings ; JD> my $read = 0; my @genes; my %hash; why the $read flag? JD> while (){ JD> chomp; JD> $read = 1 if /^GENES/; you can always just so this and test for it. i don't know the data logic so i can't go further. at l

Re: solution for Regex

2011-06-09 Thread Rob Dixon
On 09/06/2011 09:48, venkates wrote: > Hi, > > data snippet: > > ENTRY K2 KO > NAME E1.1.1.2, adh > DEFINITION alcohol dehydrogenase (NADP+) [EC:1.1.1.2] > PATHWAY ko00010 Glycolysis / Gluconeogenesis > ko00561 Glycerolipid metabolism > ko00930 Caprolactam degradation > CLASS Metabolism; Carb

Re: solution for Regex

2011-06-09 Thread John Delacour
At 10:48 +0200 09/06/2011, venkates wrote: I need to retrieve all the gene entries to add it to a hash ref. Your code is very fussy with all those substrings etc. What about something like this: #!/usr/local/bin/perl use strict; my $read = 0; my @genes; my %hash; while (){ chomp; $read =

Re: solution for Regex

2011-06-09 Thread Shawn H Corey
On 11-06-09 01:48 PM, Dr.Ruud wrote: On 2011-06-09 10:48, venkates wrote: my @gene_label_array = split '\s', $gene_label; That '\s' is more clearly written as /\s/ or for example m{\s}. But best just make it ' ' (see perldoc -f split, about that special case). FYI, some people find it har

Re: solution for Regex

2011-06-09 Thread Dr.Ruud
On 2011-06-09 10:48, venkates wrote: my @gene_label_array = split '\s', $gene_label; That '\s' is more clearly written as /\s/ or for example m{\s}. But best just make it ' ' (see perldoc -f split, about that special case). -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org F

Re: solution for Regex

2011-06-09 Thread Jim Gibson
At 10:48 AM +0200 6/9/11, venkates wrote: Hi, data snippet: I need to retrieve all the gene entries to add it to a hash ref. My code does that in the first record but in the second case it also pulls out the REFERENCE information. I have provided the code below. If some one could tell me wh