in reply to Replacing spaces
As your fields are fixed width, you should unpack them using a suitable template and then join them to put the tabs in.
In this case, the suitable template char would be 'A' (with an appropriate count), to truncate the trailing spaces in each of your left-justified fields.
Something like this should do the trick:
#! perl -sw use 5.010; use strict; while( <> ) { my @fields = unpack 'A31 A31 A26 A13 A9 A11 A31 A26 A26 A1', $_; say join "\t", @fields; } __END__ c:\test> thisScript.pl yourFile > theNewFile
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replacing spaces
by apachi15 (Initiate) on Apr 07, 2009 at 12:47 UTC | |
by BrowserUk (Patriarch) on Apr 07, 2009 at 13:37 UTC | |
by apachi15 (Initiate) on Apr 08, 2009 at 09:14 UTC | |
by BrowserUk (Patriarch) on Apr 08, 2009 at 10:11 UTC |