#each element in the array is a single line my @netlist = ; close(NETLIST); #while it is not the end of the file while($line = shift @netlist){ chomp $line; my $tmp = $line; $line = shift @netlist; chomp $line; if ($line =~ /^\+/){ # Is this a continuation.. s/^\+//; #remove the continuation $tmp = $tmp . $line; print "$tmp \n"; }else{ pop (@netlist, $line); print "$tmp"; } }