use strict; print scalar ; # print first #PLOT1 while () { chomp; # get rid of EOL print /#PLOT/ ? "\n$_\n" : "$_ "; } ## end while () __DATA__ #PLOT1 a b c d f g i a c g s h b h f d #PLOT2 b g d i s e w d u b a o n i o p w q c u s t r r y #PLOT3 e r t d v g v g b #### #PLOT1 a b c d f g i a c g s h b h f d #PLOT2 b g d i s e w d u b a o n i o p w q c u s t r r y #PLOT3 e r t d v g v g b