#!/usr/local/bin/perl use strict; use warnings; my $a_file; # you need an initial value for these names! my $b_file; # in case the if statement doesn't work # quit unless we have the correct number of command-line args if (@ARGV != 5) { print "\nUsage: $0 new_filename orig_filename domain new_tools orig_tools\n"; exit(-1); } # args my ( $new_filename, $orig_filename, $domain, $new_tools, $orig_tools ) = @ARGV; my $psconfig = "psconfig.sh"; if ($new_filename eq $psconfig) { $a_file = "/directory/$new_filename" ; $b_file = "/directory/$orig_filename" ; } open my $a_fh, '<', $a_file or die "file error $a_file: $!"; open my $b_fh, '<', $b_file or die "file error $b_file: $!"; my %first_file = map { chomp; $_ => 1}<$a_fh>; my %second_file = map { chomp; $_ => 1}<$b_fh>; print "\n--------------------------------------------\n"; print "Output from $new_tools $domain $new_filename\n"; print "--------------------------------------------\n"; foreach (keys %first_file) { print "$_\n" unless exists $second_file{$_}; } print "\n--------------------------------------------\n"; print "Output from $orig_tools $domain $orig_filename\n"; print "--------------------------------------------\n"; foreach (keys %second_file) { print "$_\n" unless exists $first_file{$_}; }