Wrap them into some C code that ensures a proper environment. On the other hand, OpenBSD features secure perl scripts. Beware the dynamic loader. If you are running setuid, it will only use trusted libraries that were scanned with ldconfig. Setgid is not enough.
Dynamic libraries are tricky.
Basically, libraries may take some action based upon your environment before your main program even gets to check its setuid status. Don't try to port libraries unless you understand this issue thoroughly. Instead, try to figure out what's going on, and what actual feature is needed. Checking the numeric value of BSD against known releases is often the right way. See the NetBSD package guide for more information.