perl vs shell scripts

can everything that can be done by perl be done elegantly using shell scripts and utilities like awk and sed? or is ir handy to know perl

thanks

oh, boy. Lemme go get my pop corn :slight_smile:

Personally, I use ksh for most everything, with a sprinkle of expect here and there. About the only thing that I have needed perl for, was to hook up my DirecTV to my computer and be able to change channels from the command line, and that's because someone already had it in perl, and I just didn't have the time to try doing it in ksh.

I would think that is is useful to know perl, even if you don't use it, because there will be a time when you'll need to troubleshoot the mission-critical script that the guy who you replaced wrote. But personally, I have yet to encounter a situation where I must use perl.

Thanks for the reply. And yes I agree completely with you that it would still be useful to know it because there will be times when someone else would have written in it and I will have to troubleshoot! :stuck_out_tongue:

Perl is quite elegant at doing many things, such as parsing/regurgitating output. If you just need to batch-rename a couple of files, well then even csh can do that!

I will, on occasion, use a perl one-liner to save myself many lines of code. Sometimes it's even to accomplish something impossible (or nearly) with the shell.

PERL One Liners

You have to appreciate that Perl is a complete programming language, so its use case is somewhat different from that of shell scripting. I generally consider shell scripting of a more-or-less glue nature. However, anything more structured I would consider a "program" and hence a programming language will be used to fulfill the requirements (that will be mostly Perl, and rarely C/C++ or PHP).

If you learn both, you will know when to use either of them. :wink:

Perl is a glue language as well. You can do what you need with sed + awk and a decent shell in unix, in my experience. There are exceptions. Driving interactive programs with stdio buffering involved means coprocesses and pipes fail. For that, as a previous commenter noted, you need expect like functionality. Both Perl and Tcl offer that (though tcl is the originating superset).
I don't use perl and feel most people should avoid it because of the tendency to use it where more common tools will do the job. But that's entirely personal and probably not a popular opinion.

Hi.

As with many things in life, balance is important with languages ... cheers, drl

thanks for the advice, guys