tags:

views:

1329

answers:

11

I'm going into network engineering and security and I will eventually need to learn a bit of Perl. In year 3 of my course, 2 years away.

So I was interested in starting a bit early, I've got the camel beside me and before indulging into this, I wanted some people to help win me over and make me want to learn Perl. What's good about it?

Why should I learn it over one of the other scripting languages?

Any and all feedback is appreciated.

A: 

Good? Well, it has a proven track record for things like text processing. It is very expressive; it allows you to do things in very many different ways. It is reasonably efficient (more so than Python, not to talk about Ruby), and has a large and supportive community.

Personally, I don't like the cryptic syntax for compound datastructures (arrays of hashes, anyone?), the concept of prefixing variables with $/#/etc. and the myriad of implicit behavior and context sensitive evaluations. But that is more a matter of Perl being incompatible with my brain. Also, from what I can tell, Perl is more on its way down than the other way around; it doesn't seem to attract as much new programmers as Ruby and Python.

But don't let that put you off learning Perl. Knowing Perl will definitely enrich you as a programmer. Take the camel book and start working your way through the Project Euler problems.

JesperE
It's hard to tell who's adding more new users. The sales of my Perl books are steady, the sale of Ruby books is climbing slightly. However, in absolute numbers I'm selling more books. Ruby's growing faster in percentages. We never meet of the programmers out there. :)
brian d foy
Perl has reached its equilibrium, while Ruby has no where to go, but up.
Brad Gilbert
A: 

Biggest reason is perl is the standard work-horse scripting language on Unix-based environments. Something like visualbasic is on Windows and AppleScript on Macs. But Perl has proven to be troublesome in big projects (see Bugzilla). It's possible to use Perl for practically anything under the sun, but you're more likely to use something else. So Learn Perl, but don't only learn Perl, you need I'd say 3 scripting languages at least under your belt. Say Python, Ruby, PHP, Lua, or something else

Robert Gould
Oh, Bugzilla has problems besides Perl. Perl has also proved tremendously useful for projects much bigger than Bugzilla, which I wouldn't even call medium-sized.
brian d foy
Agreed. Perl is not the main problem in Bugzilla.
JesperE
True, but Bugzilla is the only one I've had a chance to look at its code :)
Robert Gould
bugzilla is old old code, show me any old code which is written well by current standards.
Matthew Watson
all of my old code is written well by current standards; it's really more a function of the programmer than the language - so what does this say about old perl programmers? ;-)
Steven A. Lowe
"all of my old code is written well by current standards" -- Now that's something I don't believe. You could be Donald Knuth for all I care, it simply can't be true.
tsee
DUDES!!!!! WHY the hell are you fighting about this and down voting my answer!? I said Perl is "workhorse == true", and its necessary to learn Perl and a few more scripting lanuages. And made a little comment about Bugzilla, but that was Bugzilla not Perl and not standards or anythng GEEZ!!!
Robert Gould
Looking at my answer it's perfectly reasonable and I shouldn't get downvoted for Comments. Not that I really care about the Rep(got enough already) but this is just silly...
Robert Gould
i already upvoted you for telling it like it is
Steven A. Lowe
@tsee: well, ok, to be accurate i should say "all of my significant code in production for customers with few exceptions is well-written by current standards". I've been doing this for a very long time, and actually helped write some of the modern standards. [Love your Alaska pix BTW!]
Steven A. Lowe
+23  A: 

It has been said countless times: your code will be as maintainable as you write it to be. You can have enormous projects written in Perl if you follow the best practices (check Damian Conway's Perl Best Practices). If you'd like to be able to process any text in any given way, if you would like to write 10 lines of Perl instead of 100 lines of Java, if you would like to see why this language is the king of scripting ( :) ), Perl is for you.

Geo
+13  A: 

Learn Perl, but learn a lot of other stuff too. Perl is just a tool, so you're not choosing a religion or a career, and you don't have to choose sides.

If you have limited time, talk to some of the people doing the work that you want to do and find out what they use. You might make a list of all of the things that you need to learn, then look at where Perl fits in with that. If it's not the most important thing to learn, you might put it off.

You might be interested in my manager's level Bird's Eye View of Perl. If you think you might like Perl, you can check out my book Learning Perl, which we recently updated for Perl 5.10. It's designed as a tutorial that you can go through in about a week. If you like the language, great. If not, you haven't wasted that much time or effort.

Good luck, :)

brian d foy
+3  A: 

It’s certainly a language that gets the job done (see CPAN, if not anything else). It’s also an immensely mature and pragmatic technology that has already solved some of the problems some other languages are struggling with – the Unicode implementation is sound, the built-in code documentation system is nice, You’ve got modules to do everything You can come up with and then yet something extra (did I mention CPAN?), runs pretty much everywhere, etc. But probably the main reason I love Perl for is that it’s a language that’s fun use and has perfect documentation and user community.

zoul
+20  A: 

If you get into Perl, there's a down side -- people who will sneer: Perl is old-fashioned, Perl isn't enterprise-worthy, Perl is a write-only language, Perl doesn't do OO to their liking.

The upside is, you won't have to listen, because you will have already finished the task you were working on and be in the pub.

But seriously, Perl is not the kind of language that CS purists swoon over. But that's as it should be. Perl's a practical, get-stuff-done language. If you're going into the practical area of networks, system admin and the like, you should definitely learn it.

Apart from anything else, sooner or later you're going to have to work on a Perl script you inherit from the last guy in your job. You might as well be ready for that.

AmbroseChapel
Amen to that last part... I'm in this situation today. I made some enhancements to a .NET project, one page of which was written in Perl. Unfortunately, that page isn't working, and my eyes are glazing over at the source. So "now I have two problems," as they say.
harpo
+1 Perl isnt enterprise-worthy
Tom
"But that's as it should be. Perl's a practical, get-stuff-done language." Hmm so is Python...
Longpoke
+5  A: 

The best thing you can learn with Perl, and which you can carry over to other languages you'll learn, is the power of regular expressions.

Knowing how to use regexes + hashes + a short loop over each line in an input file is something that will be of immense use throughout your career. For example, trawling through 200,000 lines of log entries to work out when the frequency of a particular error changed from once an hour to once a minute.

Jonno Downes
A: 

Even though Perl is quite old and has probably become pretty obsolete compared to languages like Ruby and Python it's extremely simple to get started with and has few rules. I still see Perl being requested competence in many job ads as well. Personally I love to use Perl to get a quick job done, like extracting data from a large text stream or similar tasks.

Ciryon
+1  A: 

I personally advocate Python or Ruby over Perl, but in all honesty there are still some advantages Perl has.

Perl has a lot of libraries on CPAN. In most cases whatever engine you need is probably already written a few times over, and you just need to supply the glue logic. Right now CPAN lists 14618 hosted projects, compared to Python's 5093 and Ruby's 6785.

Perl is also a defacto standard. At this point you can almost count on Perl being everywhere, and there being a lot of people familiar with it. Many people are just now discovering Python or Ruby. They will not always be available on a system.

Lastly, Perl can still best both of them in many cases in performance, though its pretty close with Python.

That all said, Perl is not losing ground to Python and Ruby simply because they're new. There have always been new languages. It is losing ground because the newer generation are more elegant, incorporate higher level ideas in a more natural way, and are much more maintainable. Perl is a good language, but now there are better choices. You can learn Perl and then learn one of the newer ones as well. There is no reason not to know both.

MattG
+2  A: 

There's different tools for different tasks of course. While Perl may not be the best solution for everything, it certainly has it's place. For me, being mainly a .NET guy, Perl drove me crazy with its loosy-goosy convention for pretty much everything; then again, that's some of it's power too for developing quick scripts. For the times that I need to hop on a UNIX box, knowing Perl (along with AWK) can help in a lot of situations. A lot.

Overall, the best aspect of learning Perl, for me, was learning regular expressions. If you don't have a good grip on regex, you will after you've learned Perl. Regex is one of those fundamental tasks that you can take just about anywhere.

I'd recommending starting with the Llama book instead of the Camel book. The Llama book is more of an intro text and you'll gain a better grasp on Perl (IMHO). After you're done, then launch into the camel book.

http://oreilly.com/catalog/9780596001322/

Also, in reading the Llamma book, you'll pick up good jokes, like who wrote,

/,{5}chameleon/

Boy George

You know... comma, comma, comma, comma, comma chameleon :)

Anjisan
+1  A: 

Yes. In system/network admin work you'll end up inheriting at least some Perl, and it would be very good to be familiar enough with the language to be able to figure out what all the random 3 line scripts written by some BOFH 10 years ago with no thought to maintainence are doing, since they will be closely tied in with Important Business Processes by this point.

I don't mean you necessarily need to USE it; I mean you should be reasonably fluent in Perl, Awk, and Sed, even if you write all your new scripts in Python.

Adam Jaskiewicz