Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: #! -- why doth thou exist?

by TilRMan (Friar)
on Aug 26, 2005 at 03:07 UTC ( #486786=note: print w/ replies, xml ) Need Help??


in reply to Re: #! -- why doth thou exist?
in thread #! -- why doth thou exist?

You could even compile a Perl that reads the #! and replaces itself with the interpreter specified there!

Indeed, perl does this out of the box.

$ cat foo.sh #!/bin/sh echo 'Hello, World!' $ perl foo.sh Hello, World!

perlrun has the details, though I prefer Dominus' take in perliaq.


Comment on Re^2: #! -- why doth thou exist?
Download Code
Re^3: #! -- why doth thou exist?
by itub (Priest) on Aug 26, 2005 at 03:30 UTC
    But, as perlrun says, that trick doesn't work when the interpreter has "perl" in the name, even if it's a different version. That is,
    $ cat foo.pl #!/usr/bin/perl print "$]\n"; $ ~/bin/perl foo.pl

    will run ~/bin/perl, and not /usr/bin/perl. I think this is good more often than not.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (17)
As of 2015-07-01 20:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (19 votes), past polls