for a program i'm makin I need to be able to analyze lines like the following one
1 waarschijnlijk neiging tot suikerziekte ccaggcccac ctggagactc
and split it up in a part that containes the number
a part that containes the text
and as a last part the dna sequence ccaggcccac ctggagactc
now i can do that with the following code
- # haal de ziekte codes er uit
-
if($line =~ m/(\b[ctga]+\b)(.*)/)
-
{
-
-
$part3 = $1.$2;
-
-
# haal het einde lijn teken eraf
-
chop $part3;
-
-
}
-
-
# haal het nummer en de naam uit de string
-
if($line =~ m/(\d+)(.*?)(\b[gtac]+\b)/)
-
{
-
-
# $1 = the numeric part, $2 the text
-
# nu maken we een hash met het nummer als keyword
-
$ziektenaamhash{$1} = $2;
-
-
# we maken ook een hash waarbij het nummer verwijst
-
$ziektehash{$1} = $part3;
-
-
}
but I'm not really happy with the $1.$2 part as it forces me to use the chop operation every time.
Is there a more efficient way to be split the lines in those parts or is my code just fine?