#!/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; }