This is a discussion on Shell scripting VS perl within the Linux General forums, part of the Linux Forums category; Hi. Are there any guidelines to which (automation) problems that should be solved using shell (bash) scripts and which problems ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
kenneho staggered into the Black Sun and said:
> Are there any guidelines to which automation problems should be solved > using shell scripts, and which problems should [be] [solved] with > perl? If it has to be run before /usr is mounted, use shell. If it mostly involves invoking external programs, or you can do it in less than 40 lines, use shell. If it'd be a complete pain to do it in shell, use Perl. If none of these things apply, then use whatever you want, just take care to put in comments and document the script so that you don't say, "What was I thinking?" 6 months later. There are not huge numbers of guidelines for this sort of thing because the number of problems out there is so large, and everyone's approach to those problems is different. The previous paragraph worked for me. YMMV. -- "Cheer up, things could be worse." So I cheered up, and sure enough, things got worse. My blog and resume: http://crow202.dyndns.org:8080/wordpress/ Matt G|There is no Darkness in Eternity/But only Light too dim for us to see |
|
|||
|
On Wed, 30 Apr 2008 03:01:52 -0700, kenneho wrote:
> Hi. > > > Are there any guidelines to which (automation) problems that should be > solved using shell (bash) scripts and which problems one should solve > with perl? > You can't use Perl on a system job if it's not available while booting. like prior to when the ram disk is detatched and the drives installed. Ruben > > Regards, > kenneho -- http://www.mrbrklyn.com - Interesting Stuff http://www.nylxs.com - Leadership Development in Free Software So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 "Yeah - I write Free Software...so SUE ME" "The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society." "> I'm an engineer. I choose the best tool for the job, politics be damned.< You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one." © Copyright for the Digital Millennium |
|
|||
|
kenneho <kenneho.ndu@gmail.com> wrote:
> Are there any guidelines to which (automation) problems that should be > solved using shell (bash) scripts and which problems one should solve > with perl? No. If both is possible it's a matter of taste which one you choose. Some people may even choose something different instead of Perl. Florian -- <http://www.florian-diesch.de/> ----------------------------------------------------------------------- ** Hi! I'm a signature virus! Copy me into your signature, please! ** ----------------------------------------------------------------------- |
|
|||
|
Dances With Crows <danceswithcrows@usa.net>:
> kenneho staggered into the Black Sun and said: > > Are there any guidelines to which automation problems should be solved > > using shell scripts, and which problems should [be] [solved] with > > perl? > > If it has to be run before /usr is mounted, use shell. If it mostly > involves invoking external programs, or you can do it in less than 40 > lines, use shell. If it'd be a complete pain to do it in shell, use > Perl. If none of these things apply, then use whatever you want, just > take care to put in comments and document the script so that you don't > say, "What was I thinking?" 6 months later. > > There are not huge numbers of guidelines for this sort of thing because > the number of problems out there is so large, and everyone's approach to > those problems is different. The previous paragraph worked for me. Good advice. Add that some things are simple in shell and some things are really difficult, but simple in perl/python/... The job of a maintenance programmer (inheriting others' code) is an interesting art. "Where do I even start to fix this?" :-) Please, at least comment. Document it too, would be nice, but I'll do that if I have to when you don't. Somebody has to. -- Any technology distinguishable from magic is insufficiently advanced. (*) http://blinkynet.net/comp/uip5.html Linux Counter #80292 - - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me. |
|
|||
|
Florian Diesch <diesch@spamfence.net> wrote:
> kenneho <kenneho.ndu@gmail.com> wrote: > >> Are there any guidelines to which (automation) problems that should be >> solved using shell (bash) scripts and which problems one should solve >> with perl? > > No. If both is possible it's a matter of taste which one you > choose. Some people may even choose something different instead of > Perl. Quite, I've dabbled in perl and dabbled a bit more in python... Must say, by far, python is much more user/programmer-friendly. Even if you do write your perl in longhand (so to speak) so that it's easier to understand, it can still be awkward after 6 months to instantly know what's going on. There're still somethings, such as text processing, that perl beats python of course. As there're some things like object oriented structured programming that python beats perl at. -- | spike1@freenet.co.uk | "I'm alive!!! I can touch! I can taste! | | Andrew Halliwell BSc | I can SMELL!!! KRYTEN!!! Unpack Rachel and | | in | get out the puncture repair kit!" | | Computer Science | Arnold Judas Rimmer- Red Dwarf | |
|
|||
|
When in doubt, use perl. That's true because a lot of scripts tend to
grow beyond their original use. It is easier to write a large program in perl, especially if it does anything complicated. I have 174 personal perl scripts. (not counting my other projects such as my websites, work etc). i |
|
|||
|
Andrew Halliwell <spike1@ponder.sky.com> wrote:
> Florian Diesch <diesch@spamfence.net> wrote: >> kenneho <kenneho.ndu@gmail.com> wrote: >> >>> Are there any guidelines to which (automation) problems that should be >>> solved using shell (bash) scripts and which problems one should solve >>> with perl? >> >> No. If both is possible it's a matter of taste which one you >> choose. Some people may even choose something different instead of >> Perl. > > Quite, I've dabbled in perl and dabbled a bit more in python... > Must say, by far, python is much more user/programmer-friendly. > Even if you do write your perl in longhand (so to speak) so that it's easier > to understand, it can still be awkward after 6 months to instantly know > what's going on. That can be done with python, too. > There're still somethings, such as text processing, that perl beats python > of course. As there're some things like object oriented structured > programming that python beats perl at. Perl is a really great extraction and report language. But its OOP support is rather entertaining than really useful for bigger projects. And complex data structures tend to get confusing in Perl. Florian -- <http://www.florian-diesch.de/> ----------------------------------------------------------------------- ** Hi! I'm a signature virus! Copy me into your signature, please! ** ----------------------------------------------------------------------- |