Open GoogleCodeExporter opened 9 years ago
I found a partial solution. In _getopt change code to:
$options{'separator'} = exists $options{'S'} ? $options{'S'} : '';
if ($options{'separator'}) {
$options{'input-separator'} = $options{'separator'};
$options{'output-separator'} = $options{'separator'};
} else {
# if (exists $options{'I'}) {
# my $separator = '\|' if ($options{'I'} eq '|');
# $options{'input-separator'} = qr/$separator/;
# } else {
# $options{'input-separator'} = $DEFAULT_SEPARATOR;
# }
$options{'input-separator'} = exists $options{'I'} ? $options{'I'} : $DEFAULT_SEPARATOR_TEXT;
$options{'output-separator'} = exists $options{'O'} ? $options{'O'} : $DEFAULT_SEPARATOR_TEXT;
}
$options{'input-separator'} = quotemeta($options{'input-separator'}); # mbk added to quote characters like | for PSV files
$options{'input-separator'} = qr/$options{'input-separator'}/; # and convert it into a regexp internal representation
Also, change to the following (add \Q) in the initialization:
my $DEFAULT_SEPARATOR = qr/\Q$DEFAULT_SEPARATOR_TEXT/;
if for instance you make a $DEFAULT_SEPARATOR_TEXT='|' as I did to make a
psvgrep.pl
Also, the documentation online for specifying the option to change delimiter is
not correct.
With the change above I had to do something like
csvgrep.pl -u '-S|' '$1;$2' contacts.psv
to change to pipe separated values.
and not -S='|' or anything like that.
Original comment by mbken...@gmail.com
on 11 Jun 2013 at 11:54
Original issue reported on code.google.com by
mbken...@gmail.com
on 11 Jun 2013 at 11:22