Wednesday, March 9, 2011

Path comparison check in Perl

Problem statement : Checking 2 paths if they are from the same path.

In UNIX, we sometimes have softlinks to path. This has caused the path checking using pattern mathching is insufficient.

After much workarounds in my codes, finally, I found this. I just get the absolute path from the 2 given paths, then make comparison.

use Cwd 'abs_path';

if (abs_path($path1) eq abs_path($path2)) {
...
...
}

:)

No comments:

Post a Comment