#! /usr/bin/Perl my $file1 = "file.txt"; open(INOUT1,"<", $file1) or die "cant open output file "; foreach $line() { #chomp $line; if ($line =~ /\\/){ $line =~ s/\\\n//; if ($line =~ /\s+/){ $line =~ s/\s+//; push(@newlines,$line); }} } foreach $linw(@newlines){ if ($linw =~ m/^FILE /) { print $linw,"\n"; next; } }