in reply to Re^5: Finding the parent of a text in a file
in thread Finding the parent of a text in a file


1) how large are your input files (in lines)?
Ans : 13000 lines

What OS are you running on?
Ans : Sun Solaris and Linux

Are your input files always the same length (in lines)? With only some words changed? Or with whole new lines added?
Ans: The number of inputs lines and their contents vary depends on platform.

  • Comment on Re^6: Finding the parent of a text in a file

Replies are listed 'Best First'.
Re^7: Finding the parent of a text in a file
by Anonymous Monk on Sep 06, 2015 at 14:07 UTC
    #!/usr/bin/perl # http://perlmonks.org/?node_id=1140982 use strict; use warnings; my $filenameone = '1.pc.d'; # change to your main filename my $filenametwo = '2.pc.d'; # change to your secondary filename my @parents; # should work on linux, not sure what Solaris diff args are... open my $fh, '-|', "diff -U 999 $filenametwo $filenameone" or die $!; scalar <$fh>; # ignore first scalar <$fh>; # two lines while(<$fh>) { s/^([ +])(?=( *))// or next; $#parents = length($2) - 1; # truncate array push @parents, $_; $1 eq ' ' and next; defined and print, $_ = undef for @parents; }

    If this doesn't work, please give a small test case that shows the failure.

      Thanks a lot Anonymous Monk.
      This works awesomely on my cofig files of lines 12500 each and gives output in no time.
      Apart from testing for regular differences ,I tried inserting a blank line in the config file, and it worked there too.
      Thanks once again. :)

        Forgot to mention its working on both Linus and Sun Solaris.