This does what you need#!/usr/bin/perl-w use strict; use warnings; my %hash=(); my $key = ''; while(<>){ chomp; if($_ =~ /^>gi.*\[(.+)\]\s>gi.*/){ $key = $1; }else{ $hash{$key} .= $_; } } foreach(keys %hash){ print join("\n",$_,$hash{$_}),"\n"; }
In reply to Re^4: While loop with nested if statements
by v15
in thread While loop with nested if statements
by lairel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |