This script has the following parameters :
-h --help: this message
- -l --log: log the output to a file
+ -l --log: log the output to a file (optional if the -o parameter is given)
-o --out: ouput directory for logs (defaults to env or /tmp if !exist)
-v --verbose
my %is_holiday;
my $today = DateTime->now( time_zone => C4::Context->tz() );
-my $filename = get_filename($output_dir);
+my $filename;
+if ($log or $output_dir) {
+ $filename = get_filename($output_dir);
+}
my $fh;
-if ($log) {
+if ($filename) {
open $fh, '>>', $filename or croak "Cannot write file $filename: $!";
print {$fh} join $delim, ( @borrower_fields, @item_fields, @other_fields );
print {$fh} "\n";
);
}
}
- if ($log) {
+ if ($filename) {
my @cells;
push @cells,
map { defined $borrower->{$_} ? $borrower->{$_} : q{} }
say {$fh} join $delim, @cells;
}
}
-if ($log){
+if ($filename){
close $fh;
}
print <<"EOM";
Fines assessment -- $today
EOM
- if ($log) {
+ if ($filename) {
say "Saved to $filename";
}
print <<"EOM";