#!/usr/bin/perl -w use strict; my ($line, $spacer); while(defined($_=<>)) { s/\n//g; if ($_ =~ /^[0-9]{3,5}/) { print "$line\n" if defined($line); $line=$_; } else { $spacer = (/^\|/ || $line =~ /\|$/) ? "" : " "; $line.="$spacer$_"; } } print "$line\n"; #get last one...