my $tot = 0; my $current_ID = 1; while ( my $line = ){ chomp( $line ); if ( $line =~ /^>/ ) { $title= $line; $tot++; }else{ $seq.= $line; shift @{$hash{$title}}; push (@{$hash{$title}}, $seq); } if ($tot > $current_ID) { $current_ID ++; push (@{$hash{$title}}, $seq); $seq = ""; } }