- print &FormatOutput($Format, $Month, $Key, $Value, $PadGroup);
+ # set output file handle
+ if (!$FileName) {
+ $Handle = *STDOUT{IO}; # set $Handle to a reference to STDOUT
+ } elsif (!defined($LastIteration) or $LastIteration ne $Month) {
+ close $OUT if ($LastIteration);
+ open ($OUT,sprintf('>%s-%s',$FileName,$Month)) or die sprintf("$MySelf: E: Cannot open output file '%s-%s': $!\n",$FileName,$Month);
+ $Handle = $OUT;
+ };
+ print $Handle &FormatOutput($Format, $Month, $Key, $Value, $PadGroup);
+ $LastIteration = $Month;