It seems like a bit of an ugly hack, so if anyone knows of a module with similar functionality, please speak up!prod.pl -an -s . -d ../cgi-bin
This was written for a WinNT box. Any suggestions for ensuring portability?
Update: This is what I love about this place: see AltBlue's answer below. Short, sweet, and to the point. More importantly, it shows that I should have read the Cwd docs more closely :)
#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; }
In reply to Test to see if directories are the same by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |