Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

what does this piece of code mean?

by skyworld_chen (Acolyte)
on Apr 22, 2013 at 14:15 UTC ( #1029885=perlquestion: print w/ replies, xml ) Need Help??
skyworld_chen has asked for the wisdom of the Perl Monks concerning the following question:


i see a piece of code like this:

#!/bin/sh exec run perl -w -x -S $0 ${1+"$@"} # -*-perl-*- #!perl -w

can anybody help me to understand this? thanks.

Comment on what does this piece of code mean?
Download Code
Replies are listed 'Best First'.
Re: what does this piece of code mean?
by kennethk (Abbot) on Apr 22, 2013 at 14:43 UTC
    Essentially, this code is a little misdirection to encapsulate a Perl script inside a shell script. When it gets to the exec line, the shell re-runs the script file with perl. -x tells perl to search the file for the first occurrence of a #! that also has the word perl, and so fast forwards past all the shell script. A read-through of -S would probably also be informative, and should contain some familiar-looking code.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Hi all,

      thanks for all of your kind replies

Re: what does this piece of code mean?
by daxim (Chaplain) on Apr 22, 2013 at 14:41 UTC
Re: what does this piece of code mean?
by Anonymous Monk on Apr 22, 2013 at 14:21 UTC

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2015-11-27 15:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (731 votes), past polls