in reply to How to substitute all tabs only in a specific field

In other words, I want to substitute all <tabs/space> in the field that starts and ends with <double quotes> by <commas>.

This sounds like something you might want to do with Text::CSV, but if your input file format is always as simple as you showed, it's possible with Regexp::Common as well.

And I want to do this (if possible) on a unix command line ie : perl -pe 's/.../g' < input_file > output_file.

If you must...

$ cat in.txt a b « x1 x2 » c d « x2 » e f « x3 x4 x5 » g h « x1 \« x2 \» x3 » $ perl -wMstrict -MRegexp::Common=delimited -CSD -ple \ 's{$RE{delimited}{-keep}{-delim=>qq{\N{U+AB}}}{-cdelim =>qq{\N{U+BB}}}}{ my ($x,$y,$z)=($2,$3,$4); $y=~s/(?<!^)\s+(?!$)/,/g; $x.$y.$z }eg' in.txt a b « x1,x2 » c d « x2 » e f « x3,x4,x5 » g h « x1,\«,x2,\»,x3 »