in reply to Detecting if a folder is a symbolic link

To avoid duplicates, you can sidestep the symlink issue (because any given file might also be a symlink) by stat'ing everything you process and rejecting anything where the dev/inode pair is the same. In other words:
BEGIN { my %seen; sub process { my $entry = shift; my ($dev, $ino) = stat $entry or return; $seen{"$dev $ino"}++ or return; ... rest of processing ... } }

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.