#!/usr/bin/perl -w use strict; my $previous_line; while () { if (/;/) { chomp; $previous_line = $_; } else { print "$previous_line; $_"; } } __DATA__ Some Company; Some Street 52 12345 City1 Another Company; Another Street 63 23456 City2 Yet Another Company; New Street 11 34546 City3