Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

(Ovid) Re: perl script inside a shell script

by Ovid (Cardinal)
on Dec 12, 2000 at 02:59 UTC ( [id://46170]=note: print w/replies, xml ) Need Help??


in reply to perl script inside a shell script

As far as I am aware, you can't do it that way. The first line of the file, if it begins with #!, is a special command that shells understand to mean "run this script with the program I specify". The #!/usr/bin/perl line later on is just treated as a comment.

Cheers,
Ovid

Update: eg and chipmunk have come up with very neat solutions around the problem. But this does beg the question of why embed Perl in a shell script? Shell scripts are fast, but the overhead of loading the Perl interpreter is going to kill any performance gain of the shell script.

The only reason I could think of is if you needed a quick hack to a huge shell script. But if it's a huge shell script, it's probably better implemented as a Perl or [insert other language here] program, huh?

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

  • Comment on (Ovid) Re: perl script inside a shell script

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-09-10 21:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (9 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.