Monday, April 25, 2011

Perl hashes - effective way of iterating through the hashes

I came across this very useful link about iterating through the perl hashes. http://www.perlhowto.com/iterate_through_a_hash. All the while, I thought that I was doing pretty good with iterating through the perl hashes, untill I saw this link. It seems that best way to iterate is to use each and not the other paradigm listed in the link.

I am posting this, just to give myself a reminder, and also a note for the perl-programmers, who have overlooked this aspect. Time to do some code-refactoring/optimisation.

Sunday, April 24, 2011

The Social Network Conundrum


It seems that no one in facebook/twitter does not want to hear about the pains in others lives. Only the messages with positive connotations is percolating the masses and is gaining in popularity; which is a good sign. However, I was wondering whether this is a good sign which is when I remembered the goodness the positive vibes can bring to your life. By spreading such messages, be it inspirational quotes or post/tweet about someone being happy and all, the positive energy is made to float all along the web. Sometimes, especially when I am low, I wonder if people are even faking these posts, saying that they are happy. This thought is cynical as it is, I already know that, but still one has to agree to the fact that once in a while, people do slip in such posts, just to get attention. All in all, it is a good-sign that social network is having such a good influence in our lives, because that is where we seem to be spending a lot of time at.

PS: The reason for the title: I wanted to use the word conundrum somewhere, so I chose it; ofcourse BBT is a big inspiration for choosing this word. Still not sure whether it is the right word to use here, though.

Friday, April 15, 2011

Perl CPAN - install cpan modules easily

I managed to install a new perl module on my Snow leopard. Till now, I was of the opinion that installing perl modules is a tedious task. Thanks to CPAN, that I was proved wrong.

All I had to do was type $> cpan on the terminal.

This command took me to a special cpan shell. In that shell i installed Text::Soundex module, just by saying

(notice the new cpan prompt here)
cpan>  install Text::Soundex
done!

It is so easy and does not take a lot of time. On a side-note, Soundex is the algorithm by Donald E Knuth (Don) that will index names based on the phonetics of it. The idea is startling and is wrought with many possibilities. It would be interesting to explore the algorithm and I would try to add more details to the algorithm in my next post.

FTR: I am using perl 5.10.0 that came pre-installed with my snow-leopard. Not sure whether cpan takes care of perl version dependencies.