[sf-perl] dynamic #! line

frosty biztos at mac.com
Mon Mar 23 19:04:22 PDT 2009

I use the /usr/bin/env trick all the time.

In my case it's because I want code to happily run under a custom Perl, an OSX Perl, a macports Perl, and a few different Linux Perls, without any fancy futzing around.

However, I have never tested it for edge cases or weird/untrusted user environments.  It seems a bit risky if you're deploying code onto servers you don't control.

Also, you can't just pass  in a bunch of switches to perl if you do it this way.  That might matter to you; it doesn't to me.

-- f.

On Monday, March 23, 2009, at 06:55PM, "David Alban" <extasia at extasia.org> wrote:
>if you're in a unix environment, you'll have at least /bin/sh
>available (hopefully /bin/bash too).  could you call a shell program
>which will set the shebang line and then call the resulting program
>with all args?
>in the shell program you could do useful things, like look for
>different perl executables, perhaps md5sum them, check whether they're
>in system directories, check when they were last modified, whether
>they're group or world writeable, and perhaps take intelligent action
>if no "suitable" perl's are found.
>On Mon, Mar 23, 2009 at 5:36 PM, Matthew Lanier <matt at lanier.org> wrote:
>> i'm in a situation where I may need to set #! on a perl script at run time
>> via the environment.  I know that's technically possible, but am unsure what
>> hidden gotchas may result.  Any thoughts on that?
>Live in a world of your own, but always welcome visitors.
>SanFrancisco-pm mailing list
>SanFrancisco-pm at pm.org

More information about the SanFrancisco-pm mailing list