Unix/Linux Go Back    



Make Multile line is one line using window Perl

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member adisky123 Regarding:
Make Multile line is one line using window Perl.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 12-31-2012   -   Original Discussion by adisky123
adisky123 adisky123 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 23 December 2013, 5:57 AM EST
Posts: 58
Thanks: 5
Thanked 0 Times in 0 Posts
Finally this thread ends up with this working code

Code:
my $new='';
$flat_file='flat_file.csv';
$new_file='new_file.csv';

open('NEW',"<$new_file") || die "Error open file $new_file\n";
open('NEW1',">$flat_file") || die "Error open file $flat_file\n";

  while (my $s2=<NEW>) {
       chomp($s2);
      if($s2 =~ /ESP Client/){
        print NEW1 "$new\n"; $new='';
                $new=$s2;
      }
      else{
          $new = $new.$s2;
      }
   }
    close(NEW);
    close(NEW1);