![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
Bash or Perl?
Hi,
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? Thanks for the info. (Know of any good books in either subject?) |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
I prefer Perl, but thats just me. I'm not sure about their similarities or differences.
__________________
When will Jesus bring the porkchops? |
|
|
|
|
|
#3 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
ls -1 > output.txt # Write the current directory listing to a file grep -ir toast * # find files with the word 'toast' in print "Hello World"; # prints Hello World
# Removes the substring "cat" from STDIN and pipes it to STDOUT
while (<STDIN>) {
s/cat//ig;
print $_;
} |
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
I prefer Perl... but use bash more often for shorter scripts. Perl is a powerhouse.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 | |
|
Programming Guru
![]() ![]() |
Quote:
Heh, i have made and used non-interactive bash scripts, and i have also made interactive perl scripts. So your discription is a little off. Here's what they have posted on the bash web site: Bash is the shell, or command language interpreter, that will appear in the GNU operating system. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification. Perl is a scripting language, not a programming language (same with bash). Programming languages get compiled, where as languages like perl and bash get interpreted on the fly. Perl is very powerful. you can do alot more things with perl than you can do with bash. However that being said, bash and perl both have places where they are better than the other. Bash is for quick development of scripts for doing simple yet repetative tasks on a system (ie: some kind of cron job, or moving log files around). Where perl is much more for backup scripts, clunking through logs looking for suspect entrys and generally more difficult tasks. here's two examples of what i use bash for: -populating a server with user accounts (30+ accounts at once), without having to enter any passwords etc...(although perl would have worked well here also.) -re-formating the names of my mp3 collection. and a couple examples of what i have used perl for: -a backup script that connects to various boxes around the networks and backs up the data to a remote server (gets run by cron every day). -an irc bot that reacts to commands givin in the chat window.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
i tend to keep BASH to one-liners i can run from the command line, if i am to save it to a file for cronning, i tend to use perl. Personal Preference
|
|
|
|
|
|
#7 | ||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
Quote:
A programming language is, surprisingly enough, a language you program in. What method is used to execute the resulting code is irrelevant. C is a programming language, but so is Perl or Python. Scheme's a programming language can be compiled, or interpreted, depending on what software you use. The term "programming language" encompasses both scripting and compiled languages. Last edited by Arevos; Jan 30th, 2006 at 10:44 AM. |
||
|
|
|
|
|
#8 | |
|
Programming Guru
![]() ![]() |
sorry, in my world, programming language refers to a compiled language, scripting language refers to a interpreted language. Call me wrong or what ever you want, but that's how i view it. Although you are correct.
Quote:
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
|
#9 | ||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
Quote:
|
||
|
|
|
|
|
#10 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
![]() |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|