perl vs shell scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl vs shell scripts
# 1  
Old 01-14-2008
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
# 2  
Old 01-14-2008
oh, boy. Lemme go get my pop corn Smilie

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.
# 3  
Old 01-14-2008
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! Smilie
# 4  
Old 01-14-2008
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
# 5  
Old 01-15-2008
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. Smilie
# 6  
Old 01-15-2008
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.
# 7  
Old 01-15-2008
Hi.
Quote:
To apply the Unix philosophy effectively, you'll need more than
just C in your toolkit. You'll need to learn how to use some of
Unix's other languages (especially the scripting languages), and
how to be comfortable mixing multiple languages in specialist
roles within large program systems.

The Art of UNIX Programming, Raymond, 2004, page 322
As with many things in life, balance is important with languages ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

3. Shell Programming and Scripting

[PERL] Running unix commands within Perl Scripts

I understand that in order to run basic unix commands I would normally type at the prompt, I would have to use the following format system(ls -l); or exec(ls -l); But when I actually try to use the command, the script fails to compile and keeps telling me there is an error with this line. ... (1 Reply)
Discussion started by: userix
1 Replies

4. UNIX for Dummies Questions & Answers

how to write perl substitute command in shell scripts

How to write perl substitute command in shell script without invoking a perl script file seperately. for ex: shell script to relace IT with CSC in a file using perl substitute command. (3 Replies)
Discussion started by: param_it
3 Replies

5. Programming

Perl CGI Scripts

I need to create a webserver to run Perl CGI Scripts. Anyone have any ideas or good links? Yes I know there are lovely programs out there, but I need to build one in C. Thanks! (1 Reply)
Discussion started by: cb.mark
1 Replies

6. Solaris

Error with perl scripts...

hi on Solaris....m getting following error while running a perl script...any suggestions.... install_driver(Oracle) failed: Can't load '/usr/local/lib/perl5/site_perl/5.8.5/sun4-solaris/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: ld.so.1: perl: fatal: /home/oracle/lib32/libclntsh.so.9.0:... (1 Reply)
Discussion started by: Amardeep
1 Replies

7. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

8. Shell Programming and Scripting

Replace Perl Module name in all Perl scripts

I want to replace a Perl module name in all my Perl Scripts in the cgi-bin directory. How is it possible? I have the following statement in my scripts use myUtil; I want to change it to use myUtil777; Regards, Rahul (2 Replies)
Discussion started by: rahulrathod
2 Replies

9. UNIX for Dummies Questions & Answers

List of all PERL scripts.

Which command should I use to get the list of all the .pl scripts on the unix server... Thanks in advacne, Venky (3 Replies)
Discussion started by: venkyA
3 Replies

10. UNIX for Advanced & Expert Users

executing perl scripts

Does anybody experiencing this same problem? I am using IRIX64 ver 6.5 at work. I wrote some Perl scripts and to execute it. First I try to put the Perl script at: /$HOME/bin/perlscript then I set the correct executable 755 right to the file I make sure the PATH to the executable... (2 Replies)
Discussion started by: vtran4270
2 Replies
Login or Register to Ask a Question