I am not sure what you are trying to accomplish with the unpack A* code? I show a modified version of your code below. It does sound like "diff" or other system utility would be just as good at this? I am on Windows, but my editor has a "diff" button for 2 different editor windows (a common feature of a program editor).
I didn't test this and I'm sure there is bound to be some mistake somewhere, but be that as it may, consider this:
#!/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 ori
+g_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{$_};
}