#!/usr/bin/perl

open IN, "testfile";
$num = 1;

open OUT, ">testsoubor".$num;

while (<IN>) {
    print OUT;
    if (/comm/) {
	$num++;
	close OUT;
	open OUT, ">testsoubor".$num;
    }
}