# init variable to show we're not in the blcok my $in_block = 0; while ( <> ) # process line by line { $in_block = 1 if /^head/; # test for start of block and # set flag true if needed print if $in_block; # print if we're in the block $in_block = 0 if /tail$/; # test for end of block and # set flag false if needed }