|Syntactic Confectionery Delight|
Dev Hashbangby Xiong (Hermit)
|on Feb 19, 2010 at 14:10 UTC||Need Help??|
Xiong has asked for the
wisdom of the Perl Monks concerning the following question:
My OS is partially written in Perl. I naively installed, with a free and easy hand, many CPAN modules into library directories searched by my system perl, for which I was justly paddled. I have paid heavy penance for my foolishness by wiping my drive and reinstalling my OS, formerly polluted by oddball modules. I now plan to compile another development perl executable (and dump modules into its library space with a will).
However, tooling along the street and meditating about my plans, I stumbled upon an issue. My current project will be deployed on a remote web server. To make scripts run on it, I begin each with the hashbang #!/usr/bin/perl -T. Up to now, that's worked equally well when testing such scripts on my local machine, since that is where the system perl resides.
But if I compile another executable, it will require a different hashbang, say #!/lab/perl -T. Otherwise, dev perl present or no, my script will run on the system perl. Then, when I upload the script, I'll have to edit the hashbang.
I don't want to do this. What now?
Updates: Fascinating TMTOWTDI here!
MakeMaker schemes annoy me, sorry. When in the Wallow, I tend to edit one file, reupload, test, scratch my head, repeat. I want to tighten that inner loop, not obtrude extra steps. (I'm sure some better than I have got this down to single keystrokes invoking tar and make.)
I lied. (s/#!([^\/]+)/perl/#!\/\1\/perl -T/) I have been setting -Taint on all my uploaded scripts, for good and obvious reasons. Silly of me not to consider this context as related. I'd better pass on env. (Initiates may meditate on the pratfall I took through inadequate Laziness and false Hubris in not simply copying an actual hashbang line from one of my scripts instead of glossing it by hand.)
pl2bat is not intended for my OS, thank Torvalds. It's just as well; otherwise I'd spend an hour figuring out what that line does. Maybe I should anyway.
Debian alternatives would work well in this case, as Ubuntu is descended from it; but given my non-linear work habits, I would probably omit someday to switch perls and Encounter a Nasty Bit in my Soup. I have not yet discovered just how much of my system is written in Perl, nor do I care to commit to a strategy that forbids future developers of dancing bear desktop applets to write them in Perl. Nice idea, though.
Symlinks look good. I'd thought briefly in that direction but not in the right way. With respect, I think perhaps the more obvious solution is on localhost to install /lab/perl, on remotehost symlink /lab/perl to /usr/bin/perl, and write the hashbang line #!/lab/perl -T. This requires no Extended Study Hall on my part; I know how to work symlinks. I merely didn't think hard enough. scorpio17++
More or less idiotically, I forgot that /dev/ is used to incorporate devices into the Linux file system.