Thread: Bash or Perl?
View Single Post
Old Jan 28th, 2006, 6:11 PM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by titaniumdecoy
I want to learn a command line scripting language such as bash or Perl but I don't know the difference between them. Does Perl have all the same features as bash? Is Perl superior to bash, and if so, how? Which would you recommend?
Bash was designed for interactive use. It's much like an advanced version of the Windows command prompt. Bash is a language designed to handle running external commands, and piping their output to files, or other commands:
ls -1 > output.txt   # Write the current directory listing to a file
grep -ir toast *   # find files with the word 'toast' in
Perl, on the other hand, is much more like your classic programming language. It's not designed to be interactive, and it doesn't use external executables for its commands (at least, not often), but a number of library functions and built in commands:
print "Hello World";    # prints Hello World

# Removes the substring "cat" from STDIN and pipes it to STDOUT
while (<STDIN>) {
    s/cat//ig;
    print $_;
}
As to which one is superior - it depends on the situation. I wouldn't use Bash to write anything complex, and I wouldn't use Perl as an interactive shell.
Arevos is offline   Reply With Quote