Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: shebang line - foreign to me

by Willard B. Trophy (Hermit)
on Dec 27, 2002 at 03:25 UTC ( #222458=note: print w/ replies, xml ) Need Help??


in reply to shebang line - foreign to me

I'm rather fond of:

#!/usr/bin/env perl

as I haven't met a recent Unix system that doesn't support it.

I think it's also short for 'hash bang'.

--
$,="\n";foreach(split('',"\3\3\3c>\0>c\177cc\0~c~``\0cc\177cc")) {$a++;$_=unpack('B8',$_);tr,01,\40#,;$b[$a%6].=$_};print@b,"\n"


Comment on Re: shebang line - foreign to me
Download Code
•Re: Re: shebang line - foreign to me
by merlyn (Sage) on Dec 27, 2002 at 09:15 UTC
    Except:
    • On some systems (I forget which), it's #!/bin/env, not #!/usr/bin/env
    • I've seen recent systems that didn't have env at all.
    • It costs performance wise, with an extra fork to get to env before you get to the Perl binary.
    So, it's neither portable, efficient, nor necessary, except for sufficiently narrow values for each of those three.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Performance wise, the difference between:

      #!/usr/bin/env /usr/bin/perl

      And:

      #!/usr/bin/perl

      Is almost nothing on a P3 800Mhz running Linux 2.4.20. Using Benchmark.pm and system("program.pl") the former runs at 3875.97 times per second and the latter runs at 3906.25 times per second. The env binary is only 11 Kbytes and should fit in RAM for any program executed frequently. The env binary also only runs exec(), it does not run fork(), so sensible systems (such as Linux) that do not need to reschedule a timeslice to complete exec() show almost no penalty at all (I suspect the slight penalty is due to the loading of the elf information and performing a dependency analysis of the shared libraries associated with /usr/bin/env).

      As I mentioned in my response, one of the reasons why /usr/bin/env would be necessary is the case where perl is network-mounted and a shell script is necessary to select the correct version of perl to execute for the host platform. In this case, the issue is that it would be impossible or impractical to do this sort of thing any other way.

      As for portability, env is located in /usr/bin/env on HP-UX, SunOS, Solaris, and Linux. If perl can easily have a symbolic link created at /usr/bin/perl, then env can easily have a symbolic link created at /usr/bin/env on whatever architecture you happen to be referring to that does not have /usr/bin/env.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://222458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-08-27 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (250 votes), past polls