The hardest bit IMO isn't writing the perl code, it's making it executable on all the bizarro platforms that perl runs on. That is, to get the #! line right on Unix-a-likes, but make it a valid .BAT file on Windows, and whatever is needed on VMS.
Thankfully, there's a tool to do that.
ExtUtils::MakeMaker and, presumably, Module::Build, have the smarts to edit your scripts appropriately at install time so you don't have to worry about it. If for some reason you can't use either of those tools, then the maximally portable preamble for Unix-a-likes is:
exec perl -x $0 "$@"
# your perl code goes here
but I have no idea what to do, or even if you can, make that also portable to other platforms.