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

Re: perl script inside a shell script

by HamNRye (Monk)
on Dec 12, 2000 at 23:32 UTC ( [id://46300]=note: print w/replies, xml ) Need Help??


in reply to perl script inside a shell script

I do this alot as part of maintenance and reporting, and I know that there are basically two ways:
call "perl -e" with your script inside.
put an exec call to your perl script.

I really must say that for any perl script more than 5-6 lines long the first way is no good. The second way works great, but you wind up with the need to have a number of files to run the shell script.

Also, why not write all of it in perl?? I have not found too many thing that a shell can do that perl cannot... (Although around here we use perl scripts like libraries and allow our shell scripters to call them....) If nothing else, having all of your info in perl saves you the effort of sending a command line and parsing the output.

Finally, if you can make the shell scripty parts of your file look like comments to perl you could try this:

exec perl -e "$0" ${1+"$@"}

Hope this helps....

~Hammy

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-09-07 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    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.