print "Enter pathname of input (existing) file: "; chomp($in=); die "$in does not exist: $!" unless (-e $in); print "Enter pathname of output (non-existing) file to be created: "; chomp($out=); die "$out exists!" if (-e $out); print "Enter pathname of log file (to be created or appended to): "; chomp($log=); open(IN, "$in") || die "Cannot open $in for input: $!"; open(OUT, ">$out") || die "Cannot open $out for output: $!"; open(LOG, ">>$log") || die "Cannot open $in for append: $!"; while ($rec = ) { $n=sprintf "%8d", ++$c; print OUT "$n: $rec"; } print LOG "$c records copied from $in to $out\n\n"; print "$c records copied from $in to $out\n\n";