http://www.perlmonks.org?node_id=665593

andy314 has asked for the wisdom of the Perl Monks concerning the following question:

I need to be able to use change the ownership of symlinks in Perl, where the function "lchown" comes in handy. However my script is supposed to run an work (at least for non symlinks) on older Perl versions or builds of perl which do not support lchown.
My best working attempt so far has been:
eval('use POSIX qw(lchown);'); if (defined &lchown) { eval('sub best_chown($$$) { lchown(@_); }'); } else { eval('sub best_chown($$$) { chown(@_); }'); } # ... use best_chown from now on ....

However this seemed a little ugly (too many evals and unnatural). Is there a better way?