#!/usr/bin/perl use strict; use warnings; my $input = ( @ARGV and -f $ARGV[0] ) ? shift : "C:/csv_in/test.csv"; open( $ifh, "<", $input ) or die "$input: open failed: $!\n"; my $out_num = my $out_count = 0; my $ofh; while ( <$ifh> ) { if ( ! defined( $ofh ) or $out_count == 5 ) { if ( $ofh ) { # print closing html stuff (page trailer, etc)... close $ofh; } my $out_name = sprintf( "C:/html_out/output_%d.html", ++$out_num ); open( $ofh, ">", $out_name ) or die "$out_name: cannot open: $!\n"; # print opening html stuff... $out_count = 0; } # extract fields from data row and stuff it into html... print $ofh ... $out_count++; } # print closing html content to current $ofh ...