'sci_format|sci-format=s',
'max_digits|max-digits=i',
'rmode|r-mode|r!',
- 'remove_name|remove-name=s@',
+ 'remove_name|remove-name=s@',
+ 'output|output_file|output-file=s',
'debug|d+','help|h|?','man|m');
pod2usage() if $options{help};
$sep_char = ' ';
}
+if (not @{$options{remove_name}}) {
+ $options{remove_name} = ['.+\/',
+ ];
+}
+
my %wb_formats = ();
my $csv = Text::CSV->new({sep_char=>$sep_char});
-my $wb = Spreadsheet::WriteExcel->new(\*STDOUT);
+my $wb;
+if (defined $options{output}) {
+ $wb = Spreadsheet::WriteExcel->new($options{output});
+} else {
+ $wb = Spreadsheet::WriteExcel->new(\*STDOUT);
+}
+
for my $file (@ARGV) {
my $fh;
if (not defined $file) {
$file = "STDIN";
}
else {
- $fh = IO::File->new($file,'r') or
+ open($fh,'<:encoding(utf8)',$file) or
die "Unable to open $file for reading: $!";
}
my $ws_name = $file;
foreach my $remove (@{$options{remove_name}}) {
- $ws_name =~ s{\Q$remove\E}{}g;
+ $ws_name =~ s{$remove}{}g;
}
$ws_name =~ s{\.[^\.]+$}{}g;
$ws_name =~ s/_+/ /g;
my $t_ws_name = $ws_name;
my $maxlen = 31-length('.'.$overflow);
$t_ws_name =~ s{^(.{0,$maxlen}).*$}{$1};
- $ws = $wb->add_worksheet($ws_name.'.'.$overflow);
+ $ws = $wb->add_worksheet($t_ws_name.'.'.$overflow);
$overflow++;
$row=1;
output_row(\@header_row,$row,$ws,$wb,\%wb_formats,\%options);