Try

#!/usr/bin/perl use strict; use warnings; if (@ARGV < 2) { print "USAGE :: perl lib_marge.pl <<MAIN_LIB_FILE>> <<LIB_FILE_FOR +_MARGE>> \n\n" ; exit(1); } # read first file my $file1 = shift @ARGV; open IN,'<',$file1 or die "Can not open $file1 for input : $!"; print "$file1 opened for input\n"; my @file1 = <IN>; close IN; # remove last line pop @file1; # create new file my $outfile = 'Output.csv'; open OUT,'>',$outfile or die "Can not open $outfile for output : $!"; print "$outfile opened for output\n"; print OUT $_ for @file1; # add other files my $last; for my $infile (@ARGV){ open IN,'<',$infile or die "Can not open $infile for input : $!"; print "$infile opened for input\n"; my $flag = 0; my @lines = (); while (my $line = <IN>) { if ($line =~m/^\s*cell\s*\(\"(.*)\"\)/g || $line =~m/^\s*cell\((.*)\)/g || $line =~m/^\s*cell\s*\((.*)\)/g) { $flag = 1 } push @lines,$line if $flag; } close IN; $last = pop @lines; # remove last line print OUT $_ for @lines; } print OUT $last; # add last line close OUT;
poj

In reply to Re: Merging of files with some edit. by poj
in thread Merging of files with some edit. by anirbanphys

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.