Sunday, April 29, 2012


Three homeless boys who made a living by begging and shining shoes on trains got out of three different compartments, met on the platform and started exchanging notes. One of them had earned 5 rupees, another had earned 2. And one had nothing. But he said something that I will never forget-

"Kal maine das rupay kamaya. Sabko khana khilaya."
"Yesterday, I earned 10 rupees. I bought food for everyone."

Who was more generous?

The boy who gave everything, when he had nothing.
Or the rich man who gave 85% of his wealth, but still had a few billion dollars left.

Monday, April 23, 2012

Perl marketing and CPAN module install tests

Swartz asks us to stop running tests while installing CPAN modules. This a very good idea.

It is very important to make it easy for a beginner to install and work on any Perl module. And a beginner can not be expect to be able to use the results of the tests for anything useful.

We should make a default Perl not require tests to install CPAN modules, while an experience user should still be able to turn on tests.

This will make it faster, and easier for a beginner to actually do something productive and get to the aha moment.

We don't want people to feel the same way as they do with slow web pages or splash screens.

Saturday, April 14, 2012

Learning Perl with Testing

If you want to learn Perl, you will find many tutorials which teach you how to program. And then, when you want to learn testing, you will find other tutorials, which teach you only how to test.

Eventually, you will want to do test driven programming where you write code and tests and the same time.

Much better to learn to code and test at the same time right from the beginning.

Here is an example of how to do it in Perl.

# Recursion - convert decimal number to binary
# from Higher-Order Perl: Transforming Programs with Programs
sub binary {
my $n = shift;

return $n if $n == 0 || $n ==1;

my $k = int($n / 2);
my $b = $n % 2;

my $E = binary($k);
return $E . $b;


require "";
use Test::More;

is( binary(0), 0, "0 : 0" );
is( binary(1), 1, "1 : 1" );
is( binary(2), 10, "2 : 10" );
is( binary(3), 11, "3 : 11" );
is( binary(4), 100, "4 : 100" );
is( binary(5), 101, "5 : 101" );
is( binary(6), 110, "6 : 110" );
is( binary(7), 111, "7 : 111" );
is( binary(37), 100101, "37 : 100101" );


You can run it to see all the tests passing.
ok 1 - 0 : 0
ok 2 - 1 : 1
ok 3 - 2 : 10
ok 4 - 3 : 11
ok 5 - 4 : 100
ok 6 - 5 : 101
ok 7 - 6 : 110
ok 8 - 7 : 111
ok 9 - 37 : 100101
ok 10 - 0 : 0
ok 11 - 1 : 1
ok 12 - 2 : 10
ok 13 - 3 : 11
ok 14 - 4 : 100
ok 15 - 5 : 101
ok 16 - 6 : 110
ok 17 - 7 : 111
ok 18 - 37 : 100101

This tests that it works. Now, we think about how to break it. Lets add tests to see what our function does if we give it a negative number or a string as an input.
Lets assume that the function should return a 0 if the input is incorrect.

is( binary("a"), 0, "a : 0" );
is( binary(-1), 0, "-1 : 0" );

You see that the function fails like this:

not ok 19 - a : 0
# Failed test 'a : 0'
# at C:\Documents and Settings\others\My Documents\perl_stuff\recursion\dec_to line 53.
# got: 'a'
# expected: '0'
not ok 20 - -1 : 0
# Failed test '-1 : 0'
# at C:\Documents and Settings\others\My Documents\perl_stuff\recursion\dec_to line 54.
# got: '01'
# expected: '0'
# Looks like you failed 2 tests of 20.

So, you change your binary function to return a 0 if the input is not a positive integer, and you are done.

sub binary {
my $n = shift;

return 0 unless $n =~ /\d+/ && $n >= 0;
return $n if $n == 0 || $n ==1;

my $k = int($n / 2);
my $b = $n % 2;

my $E = binary($k);
return $E . $b;

How Perl and PHP became popular languages

Disclaimer: This is completely my imagination, and may be far from true.


First there were cgi programs. You had a web server, and you named one directory as 'cgi-bin'. Any programs in this directory were executed, and the results were sent back to the browser.

If a company wanted to have a website, they would speak to their sysadmins, who would just have to create a simple script and put it in the cgi-bin directory. Perl was already available, and it was easy to learn for someone who knew bash or awk. So, they chose Perl.

And that was how Perl first became popular.


If someone has learnt some HTML, and is able to make a website. But now wants to add some features which need a backend. Then, the easiest way to do it, especially if you are already using apache, is to use PHP.

Since there are a lot of such people, PHP became popular.

And since there are a lot more people who come from a HTML background, than from a programming background, PHP is more popular than Perl.

Perl was the king of open source web programming, but now PHP has taken its place.

The Best Marketing for Perl

"Do you like your job?"
"I love it."
"What do you do?"
"I'm a Perl programmer."

Sunday, April 8, 2012

Perl Target Markets

These are my thoughts about marketing perl in response to the discussion going on on chromatic's blog.

Before we sell a product, we first need to learn something about the people who we are selling to. At the same time, we need to focus on our strengths.

Here, I'm going to try to categorize the Perl market, so that we can decide which one to focus on, and work on it.

One way to categorize is -
  • Existing users
  • New users

We want both to use Perl for new projects. And we want existing users to stay with Perl on their current projects.

Another way to categorize-
  • Perl project maintainers
  • Job creators / Managers / Decision makers on new projects
  • Job seekers / Programmers / Testers
  • Students
  • Open Source project creators / maintainers
  • Scientists
  • System Administrators
  • Computer Science teachers

Each of these markets has different requirements, and we need to focus on different things while selling to each of them.


For a manager in a company to seriously consider a language, he must know that he will be able to find people with experience in that language, or who can pick up the language and become productive in it quickly. If we target students, they would include Perl in their resume right in the beginning of their careers and not delete it for many years.

Programmers / Testers

Most programmers would stick to the language which their work needs them to use. And it would be very difficult to convince them to learn a new language. So, students are our best bet.

In companies, Perl is already used for testing. A look at the job ads show that though Perl developer jobs are few, there are a lot of openings for Perl testers.

We need to do our best to make the Perl testing team one of the most productive and efficient teams in the company.


A student may be interested in

  • Doing what everyone else is doing (peer pressure)
  • Getting a good job
  • Impressing her professor
  • Getting that class project done on time
  • Learning new concepts
  • Easily able to get books and reference material, preferably for and online
  • Getting help easily

If you can help with all of this, you will attract new students to Perl

But, as a person the student may be interested in other things like, say, getting a date.

Now, if Perl can help the student do that, you can guarantee that they will be devoted to Perl!

Saturday, April 7, 2012

How to say Thanks

You may read advice on how to be a good leader, and see "Thank your team members whenever you get an opportunity to do so".

If you do say thanks, please say it because you actually feel grateful, and not just because you are supposed to say it.

A true leader is always genuine and never fake.