#!/usr/bin/perl use strcit; use warnings; use Tie::File; my $file=$ARGV[0] or die("No File defined!\n"); tie( my @data, 'Tie::File', $file ) or die "Can't open $file ($!)\n"; for my $pos ( reverse (0..$#data) ) { if($pos>0 and $data[$pos]=~//) { $data[$pos-1]=~s/.\n/\n/; splice(@data,$pos,1); } } print join('',@data); untie(@data);