So im trying to do this lab in perl on a solaris machine. Everything works fine until the program is setuid which it needs to be. What im trying to do is get the full path to the script itself and use that path to create files in that dir.

Im using the builtin $0 var to get the full path and file name, then using

$dir = dirname($0); // gets the path name minus the trailing /

I tried using pwd but that doesnt work unless you call the script from its directory.
This works fine, until the script is suid, at which point the $dir variable changes to /dev/fd
instead of /share/longpre/bertka.

Any ideas on how to get around this another way?