Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

(OT) Perl command line interpolation

by jesuashok (Curate)
on Jun 15, 2006 at 12:18 UTC ( #555481=perlquestion: print w/ replies, xml ) Need Help??
jesuashok has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I have done a super search before posting this node. I did not find anything related to this.

I am going ahead with that hope.

Today I saw a perl script which contains the first line as

#!/usr/bin/env perl
when I did a super search, I find lot of scripts which contains these lines, But I did not get any explanation on this.

I am familiar with the following interpolation :-
#!/usr/bin/perl
My questions are :-
1) How the interpolation happens when I give #!/usr/bin/env perl.
2) which one is faster either #!/usr/bin/perl or #!/usr/bin/env perl.


Thanks a lot. :-)


NOTE : Topic updated

"Keep pouring your ideas"

Comment on (OT) Perl command line interpolation
Select or Download Code
Re: (OT) Perl command line interpolation
by gellyfish (Monsignor) on Jun 15, 2006 at 12:28 UTC

    I don't think you mean 'interpolation'

    People use the #!/usr/bin/env perl so that they can run the program on a variety of systems where they can rely on the presence of 'env' but don't necessarily know where the perl interpreter is located. env is a utility to run a program in a controlled environment, but in this case it is used simply for it's feature that it will find the program in the $PATH. There is no other particular advantage to use it and env is not necessarily available on all Unix-like systems.

    /J\

Re: (OT) Perl command line interpolation
by jaa (Friar) on Jun 15, 2006 at 12:31 UTC
    This is not really a perl question - the shebang line is used by the shell to determine which command will handle the script.

    env is a binary that will execute your command in a modified environment -- man env is your friend!

    #!/usr/bin/env -i perl # executes perl in an empty environment - no PERL5ENV etc #!/usr/bin/env -i PERL5LIB=~/src perl # executes perl in with only specified PERL5ENV etc
    Using env to run perl might be very slightly slower - but I doubt you will be able to measure the impact.

    Regards,

    Jeff

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-09-21 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls