perl Vs Shell

D

DriVE_mE_cRazY

Hi all,

Can we write a perl script which does all the activities of a shell
script? If Yes what the advantage of using perl script in the place of
shell script.Please explain me. I'm working as a oracle DBA and i want
to write the perl script for oracle db/apps cloning which was written
in shell script.
 
M

Martien Verbruggen


There is no single yes or no answer to the above question. While you can
probably replicate a sheel script in Perl, that is not always the best
idea. Shells are generally good at calling loads of external programs,
and stringing them together in some coherent whole. As programming
languages, most shells are generally not that great. Shells also often
lack builtin functionality that you tend to find in perl, and people use
tools like awk, sed, grep, etc for that instead.

While Perl can be used to 'replace' shell scripts, I very often prefer
shell scripts, simply because the problem at hand is more easily solved
with a shell than with Perl.
Portability

That is a gross overgeneralisation. If the majority of tasks consists of
calling external programs, then portability has nothing to do with it.

I can run my shell scripts on the three Unix and unix-like OSes that I
work on, as well as on Windows and MacOS. All the 'standard' tools (or
close relatives of them) are available on all those platforms if you
want.

To the OP: use what is best for the task at hand. If almost all you have
to do is execute SQL in your database servers and work with the result
sets, then using Perl with the DBI is probably a good choice. If,
however, you need to mainly execute tools that came with your software,
a shell may be better.

Don't be afraid to use both if you do both.

Martien
 
J

Jürgen Exner

DriVE_mE_cRazY said:
Can we write a perl script which does all the activities of a shell
script?
Yes.

If Yes what the advantage of using perl script in the place of
shell script.Please explain me.

Two completely different tools. Shell scripts are good at stringing together
and batch processing external commands but lack any higher-level programming
features.
Perl on the other hand is a full-featured programming language that can also
call external commands. But if the later is all you want to do then there is
really hardly a good reason to rewrite your code in Perl.
I'm working as a oracle DBA and i want
to write the perl script for oracle db/apps cloning which was written
in shell script.

Perl has several great modules to access databases directly and work with
the data natively.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,101
Latest member
MarcusSkea
Top