http://qs321.pair.com?node_id=734830


in reply to printing the length of string variables

Hi sugar,

If I understood your requirement correctly, the below coding which is slightly modified form of yours will work. But you can do the same in more simple way.

use strict; use warnings; my ($head); while(<DATA>){ my ($x, $str, $len, $s); $s = $_; if($s=~m/^>/){ chomp($s); ($head)=(split(/ /,$s))[0]; } else{ chomp($s); $len=length($s); } print "$head length=$len\n$s\n" if($s !~m/^>/); } __DATA__ >IDnumber1 length=350 AGCTG >IDnumber2 length=350 AGAACGT >IDnumber3 length=350 AGC output: ------- >IDnumber1 length=5 AGCTG >IDnumber2 length=7 AGAACGT >IDnumber3 length=3 AGC

Prasad