Last month I attended the II Sao Paulo Perl Workshop, where I had the privilege of learning with the great talks performed by bryan d foy, Brad FitzPatrick and Larry Wall. For being a Java programmer, you can imagine how lost I was feeling there.
The first programming language that I had contact with was Perl. I was a 16 years old Slackware aficionado at that time, and was dying to have a web site with a guestbook . We did not have any cheap hosting services in Brazil that offered a PHP environment, but there were few companies that offered a free host with ads, and with Perl. I don’t remember which script I used, only that I found it in HotScripts.com and that it stored the guestbook entries in disk. Now, ten years after, here I am playing with Perl again! ![]()
Well, what was my idea of Perl before the event? I thought it was an old programming language, very powerful, but over complicated. And what do I think of Perl now? I think it is an old programming language, very powerful, but may be complicated.
Being an old programming language does not mean that it cannot dispute with newer programming languages such as Ruby, Python, Scala or Go. Actually, it means that it is old, has a plethora of examples, good documentation and a vast and supportive community (a quick note here, Perl is the programming languages with more existing modules). Larry said during his talk that Perl won’t die, but evolve with time and have its place among other programming languages.
During my four years in Mackenzie University, the programming language that I used the most was C, and the script programming language was Shell. After the talks in the workshop, I realized that Perl has the best of both worlds, but its programs do the same thing with less lines of code in C and it has more modules and is more powerful then Shell.
I still think Perl is complicated, but depending on who wrote the code.
I found some nice code in CPAN to start playing with. Neat and easy to understand and modify/maintain.
I have a bunch of programs that I use to automate some tasks or simply customize my environment (turning a folder in a PHP project for Eclipse, for instance). As I use Windows and Ubuntu, I have C programs and Batch and Shell scripts that I use in both environments. I am slowly migrating my C and Batch and Shell scripts to Perl when applicable. This will save me time compiling my C code for each OS, and will replace some scripts that were getting too long and complicated.
Perl, here we go!












Google Modern Perl and Enlightened Perl and spend some time studying Moose and Catalyst. Perl has come a very long way from those early days. For command line programs, take a look at App::Cmd and MooseX::App::Cmd.
Hey! Thank you very much Jay! I will take a look on the material you suggested. There are lots of things to learn. bryan d foy gave a quick introduction to some of the most important sites used by Perl community, like CPAN and PAUSE. Now I am slowly understanding how to use these sites, and taking notes of many cool things to try to bring into the Java community. Thank you again!
You gave a couple of very generic examples where you’d use Perl “to automate some tasks or simply customize my environment (turning a folder in a PHP project for Eclipse, for instance)” but I’d like to know a bit more.
Could you give more specific examples – even your code snippets if possible – to show what kind of things you’d rather write in Perl than in Java?
It would especially be interesting to know for a person who knows Java well but knows little or no Perl yet:
What kind of tasks could be easier after just a couple of hours of learning Perl?
Hi Gabor,
An easy example of a task that could be easier to accomplish with few hours of Perl rather than Java is calling external programs or processing many text files.
In Java you have to understand how the Runtime and Process works, sometimes you have to implement Threads to capture the output of the process. What I would need many lines of Java code, I can do in just minutes with system, exec, “ or maybe a module from CPAN
Some years ago while I was working for a national mobile carrier I was assigned the task to batch process a bunch of files that came from the billing mediation. I thought it would be an easy task with Java, however some files were bigger than 200MB, and I had implemented the program using Threads, so I was loading many big files in memory. You can imagine what happened; there wasn’t sufficient memory to process all the files in parallel. As I didn’t know Perl back at that time, I implemented a routine in Java using java.nio and scanning the files by using pointers and keeping an index in the file. This way I could make sure that there wouldn’t happen a memory overflow.
Now I realize how simple and fast it would be to implement this routine in Perl. Good that my manager didn’t know Perl too
Thanks
Nice to hear your words. I’m wonder why you think it is “complicated”, or if you think it’s more complicated than other langs and why.
For each of your everyday tasks scripts I’m sure you will find a module in cpan that fits. There are modules for almost every common (and uncommon) task. If you can’t find it, you’re probably searching the wrong way :-p
Welcome to perl-land!
Hi Diego,
I don’t know if complicated is the best word for what I am thinking. Perhaps, a different paradigm? Some time ago I had to work in a C# project, and to my surprise it was incredibly easy for me, probably because the languages are quite similar. However the more I use Perl, the more I like it. For instance, the range operators (for (1..10)…), it’s awesome! I will check if Java 7 or 8 will have such thing.
All the other programming languages might be jealous of Perl’s CPAN
Thank you!!!
I prefer App::Rad to App::Cmd. Also, consider Dancer (http://perldancer.org) as an alternative to Catalyst. Hooray for TIMTOWTDI!
Hadn’t heard of this framework yet Naveed, thanks!
I am working in a project to evaluate a web framework developed by a Brazilian company based on GWT. Right now we are comparing it with other RIA Frameworks for Java (ZK, GWT and Vaadin). Do you know if there is any RIA Framework for Perl? Or perhaps an extension for Dance or Catalyst that you have used in some project?
BTW, is there a way to tell which Perl framework a web site is using? This web site was a sponsor in the Perl Workshop – http://www.estantevirtual.com.br/, and I would like to know if they are using Catalyst or Dancer.
TIMTOWTDI!!!