--- split-logfile.in.old 2005-09-04 16:47:54.748167168 +0200 +++ split-logfile.in 2005-09-04 16:51:17.607327888 +0200 @@ -26,6 +26,9 @@ # The combined log file is read from stdin. Records read # will be appended to any existing log files. # + +use Errno qw(EMFILE); + %is_open = (); while ($log_line = ) { @@ -52,8 +55,18 @@ # yet, do it now. # if (! $is_open{$vhost}) { - open $vhost, ">>${vhost}.log" - or die ("Can't open ${vhost}.log"); + while(not open $vhost, ">>${vhost}.log") { + if ($! == EMFILE) { + $to_close = each %is_open; + while ($to_close eq $vhost) { + $to_close = each %is_open; + } + close $to_close; + $is_open{$to_close} = 0; + } else { + die ("Can't open ${vhost}.log: $!\n"); + } + } $is_open{$vhost} = 1; } #