open SRC "> file"; # print lots of stuff close SRC; #### { my %fhs; sub END { foreach (keys %fhs) { my $fh = $fhs{$_}; if ($_ =~ /\.h\.new$/) { print $fh "#endif\n"; } close $fh; if ($_ =~ /\.h\.new$/) { Clearcase::handleClearCaseElement($_); } } } sub openFile { my ($file, $header) = @_; unless (defined $fhs{$file}) { my $f; open ($f, "> $file") || die "could not open $file for output $!"; $fhs{$file} = $f; print $f $header; } return $fhs{$file}; } }