#!/usr/bin/perl -w use strict; my %colcnt; my (@text, @lhs, @rhs); my $max; my $maxcnt = 0; while () { chomp; push @text, $_; # save text for later my @chars = split //, $_; for (my $i = 1; $i < @chars; ++$i) { #skip first char (no pred) $colcnt{$i}++ if $chars[$i] ne ' ' && $chars[$i - 1] eq ' '; $colcnt{$i} |= 0; # make sure it is init for warnings $max = $i and $maxcnt = $colcnt{$i} if $colcnt{$i} > $maxcnt; } } foreach (@text) { my ($lhs, $rhs) = unpack("A$max A*", $_); push @lhs, $lhs; push @rhs, $rhs; } print "LHS:\n"; print join "\n", @lhs; print "\n\nRHS:\n"; print join "\n", @rhs; __DATA__ This script handles about how arbitrary spacing much for column skip as white space is long as there are in each column. I enough lines of text can't figure out and a "normal" dist of spaces. how to It also doesn't make do it in one pass though. any assumpions