#!/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.
In reply to Re^7: Finding the parent of a text in a file
by Anonymous Monk
in thread Finding the parent of a text in a file
by ExperimentsWithPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |