#================================================= =
# this will match all or none
#================================================= =
open(S1,"s1.txt") or die "Couldn't open s1.txt";
my @s1 = <S1>;
close(S1);
open(S2,"s2.txt") or die "Couldn't open s2.txt";
my @s2 = <S2>;
close(S2);
chomp(@s1); # remove newlines
chomp(@s2); # remove newlines
my $s1Str = join( ",", sort @s1 );
my $s2Str = join( ",", sort @s2 );
print $s1Str . "\n";
print $s2Str . "\n";
if ( $s1Str eq $s2Str ) {
print "We have a match\n";
}else{
print "Servers have distint listings \n";
}
#================================================= =
# might want to match on an entry by entry basis
#================================================= =
#
# To compare two arrays I would advise using a module
#
http://www.annocpan.org/~DAVECROSS/A...ray/Compare.pm
#
# or you can use the simple N^2 method below
#
foreach $s1val ( sort @s1 ){
foreach $s2val ( sort @s2 ){
if ( $s1val eq $s2val ){
print "We have a match: $s1val == $s2val\n";
}
}
}
-Steven
The World's Tastiest Database
http://www.iamfood.com