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.
|
---|
In Section
Seekers of Perl Wisdom