Regarding POSIX's tmpnam, you might want to check the documentation on that too:
tmpnam
Returns a name for a temporary file.
$tmpfile = POSIX::tmpnam();
For security reasons, which are probably detailed in your system's documentation for the C library tmpnam() function, this interface should not be used; instead see File::Temp.
With respect to actually writing portable code, it's probably gotten a lot easier since you tried it. File::Spec, File::Copy, improvements to glob and File::Glob etc, all help.