Category Archives: Server side (Perl 5, Perl 6)

Object Oriented Perl 5, Moose, Perl 6, Catalyst Framework

PDL A way to deal with larger arrays

If you are working in scientific domain or using bioperl where you require to deal with bulk data processing then you should seriously consider learning PDL (“Perl Data Language”). PDL is actually a way to deal with larger arrays in Perl.  It allows large N-dimensional data sets such as large images, spectrogram, etc to be stored efficiently and manipulated quickly.

To say it with the words of Karl Glazebrook, initiator of the PDL project:

    “The PDL concept is to give standard perl5 the ability
    to COMPACTLY store and SPEEDILY manipulate the large
    N-dimensional data sets which are the bread and butter
    of scientific computing. e.g. $a=$b+$c can add two
    2048x2048 images in only a fraction of a second.”

 

PDL is well suited for matrix computations, general handling of multidimensional data, image processing, general scientific computation, and numerical applications. It supports I/O for many popular image and data formats including 1D (line plots), 2D (images) and 3D (volume visualization, surface plots via OpenGL) etc.

Latest stable release of PDL is PDL-2.4.7 and can be found at CPAN or Sourceforge.

Happy learning.

Perl 6 documentation and screencast

Perl 6 is new language from Perl community. As always good documentation plays a key role in understanding new language at faster pace. Perl 6 has plenty of resources on official documentation page available on Perl foundation.

I also found some interesting screen casts by Gabor Szabo which were indeed helpful to understand Perl 6 data structures.

Happy learning!

More backtracking examples

Backtracking might be costly so one should try to avoid useless backtracking. Perl regx have  special form of parentheses: (?>…). These are called Perl’s “don’t-ever-backtrack-into-me” markers. They will tell the regex engine that the enclosed sub-pattern can safely be skipped over during backtracking. As we know that the re-matching the contents either won’t succeed or, if it does succeed, won’t help the overall match. So these markers helps to avoid useless backtracking and saves a lot of time.

Some more useful links and examples can be found at:

http://codenode.com/2010/02/28/debugging-perl-regex-backtracking/

Perl Regx documentation page Perlre on Perldoc

Perl Best Practices by Damian Conway

Backtracking with Perl Regular expression

Wikipedia says Backtracking is a general algorithm for finding all (or some) solutions to some computational problem, that incrementally builds candidates to the solutions, and abandons each partial candidate c (“backtracks”) as soon as it determines that  cannot possibly be completed to a valid solution.

What it meant for Perl:

In fact Backtracking mechanism is core functionality of languages like PROLOG. Perl implements it using regex engine.

Adding backtracking mechanism to our programming arsenal will bring alot of new functionality. This will help us solve problems that otherwise cost us alot of time and effort.

A fundamental feature of Perl regular expression matching involves the notion called backtracking, which is currently used (when needed) by all regular non-possessive expression quantifiers, namely **?+ ,+?{n,m}, and {n,m}?. Backtracking is often optimized internally.

For a regular expression to match, the entire regular expression must match, not just part of it. So if the beginning of a pattern containing a quantifier succeeds in a way that causes later parts in the pattern to fail, the matching engine backs up and recalculates the beginning part–that’s why it’s called backtracking.

I will try to explain backtracking with an example in my next post.

Thanks

Perl 6 book project on github

A Perl 6 book is in development on github. One can try and fork source code. You can catch the authors on

#perl6book on irc.freenode.net. For more info like steps to build the book, pl see the README on github.
PDF versions of this book can be found at
http://puffin.ch/perl/6/ and http://github.com/perl6/book/downloads


Enjoy learning  Perl6 logo

Modern Perl Development and Perl 6

Hi

While watching a Perl 6 video on YAPC::EU 2010, I was wondering if year 2010 is going to be big for development in Perl programming or more specifically in Modern Perl based development (Moose,Catalyst etc). There are many new exciting module on Moose/MooseX, DBIx::class, Catalyst etc are uploaded on CPAN every month. I think the biggest news is the release of long awaited Rakudo Star in July 2010. This is a stable, usable Perl 6 implementation on Parrot Virtual Machine. Congratulations to all developers/testers of this project. One can download the tar ball the release from Github. I am going to explore and develop some applications using this exciting new language Perl 6.

I will try to show some exciting features of Perl 6 in my next post.

Happy programming!

Installing Perl modules with cpanminus

While browsing CPAN I found an intersting module by Tatsuhiko Miyagawa cpanminus.  Basically, this is a script to get, unpack, build and install modules from CPAN. The best part of  is it’s dependency free, requires zero configuration, and stands alone. When running, it requires only 10MB of RAM. [Source: CPAN]

There are Debian packages, RPMs, FreeBSD ports, and packages for other operation systems available. If you want to use the package management system, search for cpanminus and use the appropriate command to install.

You can also build from latest source itself.

I have tried it on my CentOs 4.6 and Windows XP machine. Some of the advantages which I can see at first place are:

  • It seems to consume lesser memory than traditional like CPAN and CPANPLUS which sometime goes out of the memory for heavy installation.
  • It’s provides really quiet installation in comparison to CPAN. Not many questions.
  • I think it’s good for beginners
  • Automates installation and install dependencies without CPAN installed so no need to download TAR unpack, makefile, make, make test stuff.

Will try to get some  more findings.

Cheers,