print "output file name: \n"; chomp($outfile=); open (DATA, "+>$outfile" ) || die; #### sub countprog{ my $pos=0; my $printblock=0; while() { #do a load of various things looking line-by-line at my data print DATA2 "results of this 2nd subroutine"; }