use strict; use warnings; open ( my $in ,"intxt.txt") || die "check the input file...not able to open $!"; open ( my $out ,">output.txt") || die "check the input file...not able to open $!"; $/=""; my $in_whole= <$in>; $in_whole=~ s/\n//g; my @arr=split(">",$in_whole); my $fout=join(">",@arr); print $fout; $fout=~ s/>/\n>/g; $fout=~ s/^(\n)//; $fout=~ s/\s/,/g; $fout=~ s/length=//g; @arr=split(">",$fout); $fout=join(">",@arr); $fout=~ s/>/\n>/g; $fout=~ s/^(\n)//; $fout=~ s/,\n/\n/g; print $out $fout; close($in); close($out);