#!c:/perl/bin/perl use strict; use warnings; open(FH,"C:/csv_in/test.csv") || die("cannot open the file $!"); my $header="HTML OUTPUT"; my $count=0; while(my $line=){ if($line=~/M|F$/){ $count++; if($count <= 5){ open(OUT,">C:/html_out/output_1.html") or die("cannot open $!"); print OUT $header; my @fields=split /,/, $line; print OUT ("", (map {qq{}} @fields), ""); }elsif($count > 5 && $count <= 10){ open(OUT1,">C:/html_out/output_2.html") or die("cannot open $!"); print OUT1 $header; my @fields=split /,/, $line; print OUT1 ("", (map {qq{}} @fields), ""); }elsif($count > 10 && $count <= 15){ open(OUT2,">>C:/html_out/output_3.html") or die("cannot open $!"); print OUT2 $header; my @fields=split /,/, $line; print OUT2 ("", (map {qq{}} @fields), ""); } close OUT; close OUT1; close OUT2; } #if($count > 5){ } close FH; test.csv -------- Name DOB Sex John 1/1/1980 M Kathy 2/2/2987 F Mike 3/3/1999 M Stella 4/4/1985 F Robert 5/5/1991 M Britto 6/6/1993 M Katherine 7/7/1991 F vicky 8/8/1992 M charles 9/9/1992 M stephen 10/10/1968 M Denzel 11/11/1996 M

Test HTML

categoryNameDOBSEX
$_
$_
$_