views:

53

answers:

1
#!/usr/bin/perl

This is the shebang line to a lot of scripts I'm writing lately.

Hard coding the path of the binary seems like it could create some problems. For instance, if one of my users has Perl installed at /something_else/bin then they'd have to change all the shebangs.

I've seen some tools that will automatically replace the shebangs, but I'm wondering if there is something simpler.

+7  A: 

env(1)

#!/usr/bin/env perl
Ignacio Vazquez-Abrams
what is /usr/bin/env is somewhere else on their system?
Mike
Then it most likely will be there *as well as* in `/usr/bin`.
Ignacio Vazquez-Abrams
You *could* maybe just use "#!env perl" of "#!perl" and rely on the path being set (But I don't like it).
Brenton Alker
@Brenton, sorry $PATH is not parsed by #!.
Joshua
Ah, true... knew there had to be a reason I hadn't ever seen it done :)
Brenton Alker