Gossamer Forum
Home : General : Perl Programming :

multiline text/paragraph to single array element

Quote Reply
multiline text/paragraph to single array element
Hello all,
I've got a few files to extract information from, and i am having trouble with the multi-line query. i have paragraphs of information with a info line, followed by mulitple lines of text with no spaces, folowed by a blank line.
Code:

>infoline
manylinesof
text

>infoline
manylinesof
text

i really need each seaction ie paragraph without infoline
of" manylinesoftext" each to be stored as 1 element of an array, and the infoline to be stored in a second array. i have writen a multiline regexp but i think it stores all the txt paragraphs in 1 element. the code is below
Code:
$i=0;
while($line=<INPUT1>){

if($line=~m/^[a-z].*?\b$/xm){
$array[$i]= $line;
#print $array[$i];
print OUTFILE "$array[$i]";
$i++;

}

elsif ($line=~/^[>].*?/){
push @headers, $fastafile;

$i++;
}
else{}

}
i was then going to reference each txt paragraph to $i-1 infoline. Any help on getting these of these multiline sections into seperate elements will be grateful.
txpipSmile
Subject Author Views Date
Thread multiline text/paragraph to single array element tzpip 3630 Aug 8, 2003, 6:44 AM
Post Re: [tzpip] multiline text/paragraph to single array element
Andy 3539 Aug 8, 2003, 7:50 AM