in reply to -e stransgeosities

You seem to be using relative filenames. Maybe your current directory is not the same.

my $d2 = 'myotherdir/filename'; ...

Here you seem to be using absolute filenames:

dbg> x $d2 0 '/myotherdir/filename'

Maybe your variables $d1 and $d2 are not what you think they are. Print them before doing the checks. Maybe they contain unexpected whitespace or unexpected slashes, or just are not what you expect.

Also, you are talking about "directories", but then have /filename in your paths. I suggest that you post the output of find . together with a short script that does the operations you mention. In most of such cases I've encountered, the variables tested didn't contain what I expected.