Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Difference between a perl script & shell script

by matija (Priest)
on Dec 19, 2005 at 13:23 UTC ( [id://517709]=note: print w/replies, xml ) Need Help??


in reply to Difference between a perl script & shell script

It's easier to port a perl program then a shell script.

(Or as Larry Wall said, "it's easier to port a shell then a shell script")...

Replies are listed 'Best First'.
Re^2: Difference between a perl script & shell script
by matija (Priest) on Dec 19, 2005 at 13:54 UTC
    Actualy, one of the first "I love perl" moments, for me came when I was moving programs between an SGI and a SunOs machine, back in the time when Perl was at version 4.19 and dinosaurs roamed the earth.

    For some reason, the user shell on the SunOS (not in general, just on that particular machine) was mandated to be tcsh, and on the SGI it was bash. Or maybe it was the other way around.

    Either way, porting shell scripts was a pain, porting C programs was a pain, but Perl scripts simply copied over. Nifty...

      For some reason, the user shell on the SunOS (not in general, just on that particular machine) was mandated to be tcsh, and on the SGI it was bash. Or maybe it was the other way around.
      I don't get this. Just because a users shell is tcsh doesn't mean that every shell program needs to be in tcsh - if the top line says #!/usr/bin/sh, it will be run in sh, regardless of the users shell.

      The only exception being shells that need to be "sourced" - but you can't write those in Perl anyway (unless your shell is Perl).

      Perl --((8:>*

        Unless the admin has done

        ln -s /usr/bin/sh /usr/bin/csh

        And/or for added entertainment value:

        $ stat -c %N /usr/bin/csh ,,/usr/bin/csh" -> ,,/bin/bash"

        Yes I've seen this on production systems :-/. I personally find it much easier to test and rely on Perls $] than the various wacky shell configurations out there. YMM undoubtedly V.


        Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan
Re^2: Difference between a perl script & shell script
by Perl Mouse (Chaplain) on Dec 19, 2005 at 13:46 UTC
    It's easier to port a perl program then a shell script.
    OTOH, there's less need to port a shell script than a Perl program. I've never had the need to port a shell script written in the Bourne shell to the C-shell, or from ksh to zsh. And I cannot recall ever to have written a shell program (and I have written many) that didn't work on a version of the shell five years old.

    However, every now and then, I do need to adapt a Perl program because it needs to run on an older version, or because it no longer runs (or no longer runs warnings-free) on a newer version of Perl.

    Furthermore, any Unix will have a shell that's Bourne shell compatible. Not every Unix will have Perl installed - specially not during OS-installation phase.

    Perl --((8:>*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-29 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found