#!/usr/bin/perl use strict; use warnings; ; ; # skip header lines while () { my @fields = / (.{51}) (.{21}) (.{21}) (.{21}) (.+) /x or next; my @fields_nospace = map {/^\s*(.+?)\s*$/; $1} @fields; print join ("\t", @fields_nospace), "\n"; } __DATA__ (your data here)