I want a hash structure, each line starting with a > is the key and the lines up to the next > are the value for that key:
while (<DATA>) {
$line1 = $_;
chomp($line1);
if ($line1 =~ /^>/) {
while (<DATA>) {
last if $line1 =~ /^>/;
$value .= $_;
}
$hash{$line1} = $value;
}
}
foreach my $key(%hash) {
print "$key :$hash{$key}\n";
}
__DATA__
>label1
line1\n
line2\n
>label2
line1\n
line2\n
1 Answer