Archive for the ‘Perl’ Category

Embedded Perl using Mason

June 2, 2011 Leave a comment

I have been thinking to write about ‘Mason’ for long time and finally its here now!

Why ‘Mason’?

When it comes to do more organized approach for designing the whole application platform, you certainly have to choose some template mechanism. Templating modules like HTML::Template are appropriate for light weight solutions. But when we need more manageable sophisticated system, if we choose just the templating solution, we may end up writing too much code to manage the whole system. Then that’s where ‘Mason’ helps to integrate the application with the backend systems and with caching and error handling.

If you need just simple couple of templates for the application, HTML::Template is the way to go. As I said, its the light weight solution and is very fast in rendering the pages by filling up the template variables.

Mason can be downloaded and installed similar to any other CPAN module. My personal recommendation is to use Mason along with mod_perl to boost up the performance.

For more information click here. Its a very good starting point to learn about ‘Mason’.

Categories: HTML::Mason, Perl

Komodo Edit 6.1 – IDE for Perl,Python

May 24, 2011 Leave a comment

After testing and trying couple of IDEs which are available on the net, I found Komodo Edit, very good IDE for the development of Perl and Python.

Its the free, lighter version of full fledged Komodo IDE. I did install the latest version 6.1 on Ubuntu 11.04 and here are the steps I followed:

(1) Open the link in Ubuntu browser and click on the Download for Linux button and save the tar.gz file
(2) Unzip the tar file contents to local directory and run the script.
(3) After installation, add the komodo Edit to the PATH.
(4) You can invoke the IDE by running command ‘komodo’.

Categories: IDE, Perl

Power of mod_perl

May 3, 2011 Leave a comment

What are the choices when the whole enterprise level application, written in old CGI code, is not performing as you expected?

One of the solutions you can adapt is to port the cgi code into mod_perl environment. Apart from speeding up the CGI scripts, it can do lot more other things like providing direct access to whole Apache API from perl. It embeds the Perl Interpreter into the Apache Web Server.   There are couple of guidelines explained here and its a very good starting  point.

CGI code can be tweaked in such a way that it works fine in mod_perl environment without re-writing the whole code itself. Of course one need to have a very closer look at the ‘Global Variables’ in the existing code.

Enjoy the power of coding!

Categories: mod_perl

How to search for pattern in a file and remove the previous 2 lines including the line with pattern ?

April 4, 2011 Leave a comment

How to search for the pattern in a file and remove the previous 2 lines including the line with pattern ?


my @buffer;
while ( ) {
if (!/pattern/) {
push @buffer, $_;
} else {
push @buffer, $_;
delete @buffer[-3..-1]; ## Remove 2 lines above including pattern!
print @buffer;

Categories: Perl, Perl - Examples Tags: ,

Perl Frameworks

April 4, 2011 Leave a comment

What’s the best way to write a CGI application in Perl?
Absolute answer is, using Perl Framework. There are many frameworks available with or without MVC architecture empowered. You can get a list with comparison in this link.

My personal choice is to go with CGI::Application since its very light-weight and easily maintainable. Templates can be designed using amazing perl module called HTML::Template. I found this framework magical mainly for AJAX calls using jQuery along with CGI-Application-Plugin-AutoRunmode module.
If you have existing perl code using CGI::Application and want to migrate the same to mod_perl environment, there is a CPAN module (CGI::Application::Plugin::Apache) available to do so.

You can refer to this tutorial to start using the CGI::Application. Enjoy coding!