prod.pl -an -s . -d ../cgi-bin #### #C:\perl\bin\perl.exe use warnings; use strict; use Cwd; my $source = '.'; my $target = '../cgi-bin'; print sameDirectory( $source, $target ) ? 'Same' : 'Different'; sub sameDirectory { my ( $dir1, $dir2 ) = @_; my $currentDir = getcwd(); chdir $dir1 or die "Can't CD to $dir1: $!"; my $realDir1 = getcwd(); # Need to change back in case they were using relative directories chdir $currentDir or die "Can't CD to $currentDir: $!"; chdir $dir2 or die "Can't CD to $dir2: $!"; my $realDir2 = getcwd(); # Return them to their home directory chdir $currentDir or die "Can't CD to $currentDir: $!";; return $realDir1 eq $realDir2 ? 1 : 0; }