in reply to output using map
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{$_}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: output using map
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 | |
|
Re^2: output using map
by coding_new (Sexton) on Mar 09, 2020 at 13:19 UTC |