X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=txt2xls;h=c79fb53b2d1c2ff63594602f14c280b34ac97cbc;hb=dcce90e77c92202b5fadca48de6fd1cefc41ff79;hp=ce3696590a687ba5543eb7d471c3eda3bbe3745a;hpb=85cca644061f3d76aef9af343bc5438b0c8adc9a;p=bin.git diff --git a/txt2xls b/txt2xls index ce36965..c79fb53 100755 --- a/txt2xls +++ b/txt2xls @@ -101,7 +101,8 @@ GetOptions(\%options, '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}; @@ -132,9 +133,20 @@ elsif ($options{ssv}) { $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) { @@ -142,12 +154,12 @@ for my $file (@ARGV) { $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;