use strict; use warnings; my @array = ; chomp @array; for my $index (0 .. $#array) { next unless $array[$index] =~ /'/ && exists $array[$index + 1]; $array[$index] .= $array[$index + 1]; $array[$index + 1] = ''; } @array = grep {length} @array; print join "\n", @array; __DATA__ I' m guessing I' d use join somehow