http://qs1969.pair.com?node_id=1075725


in reply to OS independent perl script

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:

#!/bin/sh exec perl -x $0 "$@" #!perl # 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.