Dear friends, can anybody correct me...I have a text file.Data look like this: 10 20 20 20 20 10 20 20 10 20 20 20 and so one ------------------------------------------------- while (<STDIN>) { if (substr($_,0,2) eq "10") { #If left 2 characters is 10,then ..... ++$count; $lines = 0; open OUT, ">$count.out"; print OUT $_; };
if (substr($_,0,2) eq "20") { #If left 2 characters is 20,then ..... ++$lines; #Counts he lines if ($lines == 4){ print OUT "Someinfo\n";$lines = 0;}; print OUT $_;}; } __EOF__ Now is: if lines count of type "20" is 4, print "Someinfo" after 4 line. How I can fix the code, if lines count of type "20" is less that 4(for exp 1,or 2,or 3), and I need print "Something" after last line of "20"? Here is example of how to output must be look. 10 20 20 20 20 Someinfo 10 20 20 Someinfo 10 20 20 20 Someinfo 10 20 20 20 20 Someinfo 20 20 20 20 Someinfo 20 20 20 20 Someinfo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]