hi,

i need to delete all blank lines from the text file 


wrote following code. however, all the blank lines are not getting deleted. 
please suggest 


open FILE,"+<", 'C:\Users\bvcontrolbuild\Desktop\test.txt';

 while (<FILE>)
       {
        chomp;
        push (@lines, "$_\n");
       }
  close FILE;
 
open FILE,">", 'C:\Users\bvcontrolbuild\Desktop\test.txt';

foreach (@lines)
      {
     
       if ($_ =~ m/^\n/)
       {
        print "hi\n";
        $_ =~ s/^\n//;
        }
        else
        {
         print FILE "$_\n";
         }
         
     }
     
     close FILE;


regards

Reply via email to