Perl Monks, I need some assistance better understanding an issue. I have a script that compares two files and produces an output of differences from the second file . The issue I am having is adding an additional code to produce the differences from the first file it does not output anything or produce any errors. Below is my script.

#!/usr/local/bin/perl use strict; use warnings; my $a_file; my $b_file; # quit unless we have the correct number of command-line args my $num_args = $#ARGV + 1; if ($num_args != 5) { print "\nUsage: name.pl new_filename orig_filename domain new_tool +s orig_tools\n"; exit; } # args my $new_filename=$ARGV[0]; my $orig_filename=$ARGV[1]; my $domain=$ARGV[2]; my $new_tools=$ARGV[3]; my $orig_tools=$ARGV[4]; 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 %second_file; print "\n--------------------------------------------\n"; print "Output from $new_tools $domain $new_filename\n"; print "--------------------------------------------\n"; @second_file{map { unpack 'A*', $_ } <$b_fh>} = (); while (<$a_fh>) { print unless exists $second_file{unpack 'A*', $_}; } my %first_file; print "\n--------------------------------------------\n"; print "Output from $orig_tools $domain $orig_filename\n"; print "--------------------------------------------\n"; @first_file{map { unpack 'A*', $_ } <$a_fh>} = (); while (<$b_fh>) { print unless exists $first_file{unpack 'A*', $_}; }

In reply to output using map by coding_new

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.