$0 == /share/longpre/bertka/path.pl when not setuid
$0 == /dev/fd/4 when setuid

im not sure what happens in the dirname sub. I should have made it clear about what the issue was, sorry. Its not with the dirname sub but with perls internal variable $0
good job on finding my linux/solaris typo.