coding_new has asked for the wisdom of the Perl Monks concerning the following question:
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*', $_}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: output using map
by Fletch (Bishop) on Mar 06, 2020 at 20:27 UTC | |
|
Re: output using map
by Marshall (Canon) on Mar 06, 2020 at 23:12 UTC | |
by AnomalousMonk (Archbishop) on Mar 07, 2020 at 00:46 UTC | |
by Marshall (Canon) on Mar 07, 2020 at 01:35 UTC | |
by Anonymous Monk on Mar 07, 2020 at 06:57 UTC | |
by coding_new (Sexton) on Mar 09, 2020 at 13:19 UTC | |
|
Re: output using map
by jo37 (Curate) on Mar 07, 2020 at 08:51 UTC |