Category Archives: Perl

Perls of wisdom (hopefully!). I can’t believe I’ve not put all my useful Perl stuff up here unti now (Jun 14).

Remove Whitespace using Perl

If you need to remove white space from say a CSV file that has been spooled by SQLPLUS, then try this:

 perl -pi.bak -e "s/^ *//g;s/ *,/,/g;s/, */,/g" C:\working\Batch\spooled_output.csv

This will remove leading spaces and any spaces in between comma separated values.

It will also create a *.bak file of your original.