#!/usr/bin/perl my $hostname = $ARGV[0]; my @hostFiles = ("filecheck.pl", "hostscript.pl", "awesomeness.txt"); my @output =`ssh $hostname "cd Desktop; ls -a"`; my %comparison; for my $file (@hostFiles) { $comparison{$file} +=1; } for my $file (@output) { $comparison{$file} +=2 } for my $file (sort keys %comparison) { @missing = "$file\n" if $comparison{$file} ==1; #print "Extra file: $file\n" if $comparison{$file} ==2; print @missing; } my @checkedMissingFiles; foreach my $var ( @missing ){ if ( ! grep( /$var/, @checkedMissingFiles) ){ push( @checkedMissingFiles, $var ); } } print "\n\nThe missing Files without dups:\n @checkedMissingFiles\n"; Password: awesomeness.txt ##This is what is printing after comparing the two arrays awesomeness.txt filecheck.pl filecheck.pl filecheck.pl hostscript.pl hostscript.pl The missing Files without dups: ##what prints after weeding out duplicates hostscript.pl