NSA: Please Turn off the Lights When You Leave. Nothing to See Here.

Linux Advocate Dietrich Schmitz shows how the general public can take action to truly protect their privacy using GnuPG with Evolution email. Read the details.

Mailvelope for Chrome: PGP Encrypted Email Made Easy

Linux Advocate Dietrich Schmitz officially endorses what he deems is a truly secure, easy to use PGP email encryption program. Read the details.

Step off Microsoft's License Treadmill to FOSS Linux

Linux Advocate Dietrich Schmitz reminds CIOs that XP Desktops destined for MS end of life support can be reprovisioned with FOSS Linux to run like brand new. Read how.

Bitcoin is NOT Money -- it's a Commodity

Linux Advocate shares news that the U.S. Treasury will treat Bitcoin as a Commodity 'Investment'. Read the details.

Google Drive Gets a Failing Grade on Privacy Protection

Linux Advocate Dietrich Schmitz puts out a public service privacy warning. Google Drive gets a failing grade on protecting your privacy.

Email: A Fundamentally Broken System

Email needs an overhaul. Privacy must be integrated.

Opinion

Cookie Cutter Distros Don't Cut It

Opinion

The 'Linux Inside' Stigma - It's real and it's a problem.

U.S. Patent and Trademark Office Turn a Deaf Ear

Linux Advocate Dietrich Schmitz reminds readers of a long ago failed petition by Mathematician Prof. Donald Knuth for stopping issuance of Software Patents.

Showing posts with label RedMonk. Show all posts
Showing posts with label RedMonk. Show all posts

Friday, March 15, 2013

Perl: The Language Everybody Wants to Declare Dead

by +Dietrich Schmitz

I keep looking, but I still haven't found a language that compares with Perl.  The level to which one can go with it soars above other languages with ease.  Perl will take you through a project and provide the deliverables.

It seems that many react and cringe when they hear the word Perl.  It's a funny reaction to me.  Because, all of the documentation for Perl is superb.  Writers like +Randal L. Schwartz or +Gabor Szabo will guide you with great thoughtful tutorials in their respective books and on-line websites.

My reaction to comments to the negative is that most are ill-informed and if a prospective student were to spend just two hours reading +Randal L. Schwartz's Learning Perl, they will have built a solid foundation upon which to expand their technical skill set.

Perl is found resident on most Unix, BSD, and Linux systems by default.  It often plays a large part in many 'behind the scenes' activities running on your system.  If you invest the time to learn, I would say it would not be a wasted effort as once done, Perl will be their in your toolbox for you to grasp and use on so many occasions throughout life.

Will Perl eventually die?  Some say it will.  But if you go by a recent study from RedMonks that measures the spectrum of programming languages in use on GitHub, it is evident that Perl is quite alive and well.


The RedMonk Programming Language Rankings: January 2013



Put forth the initial effort to learn Perl.  While the initial hill climb is steep, once mastered, Perl is powerful in the hands of the learned.  Perl can and does do the 'heavy lifting' in so many ways as exemplified by the CPAN repository.  CPAN is one step away  for anyone with Perl with a diverse set of open source modules ready to fill gaps in your programming needs.

Perl isn't just for writing projects; it is also good for quick 'one-off' utilitarian functions and can be quite convenient when invoked right from the Bash command line.  This one-liner upper-cases an entire text file:

$ cat sample.txt
Practical Extraction Report Language

$ perl -pi  -e “tr/[a-z]/[A-Z]/” sample.txt

$ cat sample.txt
PRACTICAL EXTRACTION REPORT LANGUAGE


Often, I visit +Gabor Szabo's excellent Perl5 Maven website to see what he is up to and come away learning something I didn't know before.  At his site you'll find his most excellent new book Perl Maven for Beginners, including in eBook downloadable format.  You can also find regular posts of his ideas and a dedicated section to tutorials especially made to coddle and encourage the newcomer to venture into this feature-rich, powerful programming language.  Here's a tutorial on reading a comma separated value (CSV) file and the requisite code:

#!/usr/bin/perl
use strict;
use warnings;
 
use Text::CSV;
 
my $file = $ARGV[0] or die "Need to get CSV file on the command line\n";
 
my $csv = Text::CSV->new ({
  binary    => 1,
  auto_diag => 1,
  sep_char  => ','    # not really needed as this is the default
});
 
my $sum = 0;
open(my $data, '<:encoding data-blogger-escaped-die="" data-blogger-escaped-fields="$csv-" data-blogger-escaped-file="" data-blogger-escaped-my="" data-blogger-escaped-n="" data-blogger-escaped-not="" data-blogger-escaped-open="" data-blogger-escaped-or="" data-blogger-escaped-ould="" data-blogger-escaped-utf8="" data-blogger-escaped-while="">getline( $data )) {
  $sum += $fields->[2];
}
if (not $csv->eof) {
  $csv->error_diag();
}
close $data;
print "$sum\n";

I can assure you from experience that for every 1 line of Perl, writing an equivalent piece of code in C will yield a ratio of 10 or more lines to accomplish same.  This is not to suggest that Perl serves to replace the venerable C language--certainly not.  But there are many applications where Perl excels and is the right tool for the job, particularly systems integration and the Internet web development.

So, please.  Make the investment.  Randal and Gabor will be there to help you.  I promise.   Learn Perl and it will be with you to serve your needs always.

-- Dietrich
Enhanced by Zemanta