The inode number alone is not enough, you also have to compare the device number from stat, because the inode numbers are unique only within each filesystem.
The dev-inode pair usually identifies the file uniquely, but of course there are some caveats.
-
Perls are normally compiled with 64-bit file access, and you might need that for this trick too, because it makes inode numbers wider.
-
Device numbers might not be constant over a reboot. (They often are, but not always.)
-
Under linux, if you see a file through a bind mount, it gets the same device-inode pair as the file on the original mount, so it's possible to have two file names that refer to the same underlying file but one of them is read-only.
-
Probably more stuff I don't know about.