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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |