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 install.sh script.
(3) After installation, add the komodo Edit to the PATH.
(4) You can invoke the IDE by running command ‘komodo’.

Categories: IDE, Perl

Why use LDAP?

May 10, 2011 Leave a comment

LDAP is an application layer protocol which specifies how data can be accessed through a directory based on X.500 standard.

LDAP directory service has following main features :

(1) Data is written once and need to be read multiple times; Basically the idea here is LDAP perform well where modifications to the schema happens not very often. Transactional data design may not fit into LDAP.

(2) It provides very standardized way of data access, so no need of vendor specific code modifications required if it needs to be ported to different environment.

(3) The LDAP server can be configured with indexes on any attribute, so searches can be made very efficient and large data volume can be handled without any performance penalties.

(4) User authentication and authorization: LDAP provides many security options to secure the communications along with support of SSL/TLS.

Categories: LDAP

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

RubyOnRails(RoR) on Ubuntu 10.10

April 14, 2011 Leave a comment

Recently I had installed RubyOnRails on Ubuntu 10.10. If you are a beginner, you would find very much confusing to understand why those components were required in the first place.All we need is just couple of commands as below to get RoR application up and running!

sudo apt-get install ruby
sudo apt-get install gems
sudo gem install rails
mkdir <Application Directory Path>

rails new <Application Directory Path>
sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby
cd <Application Directory Path>

rails server

Installed Versions:
Ruby 1.8.7
RubyGems 1.3.7
Rails 3.0.6

Here are some tips and observations :

(1) Tried to install with ‘sudo gem install rails’ and it gave ‘File not found: lib’ error
$ sudo gem install rails
Successfully installed rails-3.0.6
1 gem installed
Installing ri documentation for rails-3.0.6…
File not found :lib

sudo gem install rdoc-data
sudo gem rdoc –all –overwrite
Then run ‘sudo gem install rails’.

(2) sudo gem install rails hangs or takes too much time
When I ran the command, it seems like it was hanging, but apparently it came back with successful installation. So even though it seems like taking too much time, hang in there.

$ sudo gem install rails
Successfully installed rails-3.0.6
1 gem installed
Installing ri documentation for rails-3.0.6…
Installing RDoc documentation for rails-3.0.6…

(3) Dont forget to add the GEM path to PATH
$ gem env
RubyGems Environment:
– RUBY VERSION: 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
– INSTALLATION DIRECTORY: /var/lib/gems/1.8
– RUBY EXECUTABLE: /usr/bin/ruby1.8
– EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
– ruby
– x86-linux
     – /var/lib/gems/1.8
– /home/testuser/.gem/ruby/1.8
– :update_sources => true
– :verbose => true
– :benchmark => false
– :backtrace => false
– :bulk_threshold => 1000

$ export PATH = $PATH:/var/lib/gems/1.8/bin
(4) ‘Could not find sqlite3’ error while running “rails server” even after trying to install using sudo gem install sqlite3
$ rails server
Could not find gem ‘sqlite3 (>= 0, runtime)’ in any of the gem sources listed in your Gemfile.

sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby

Good Resource Link is here!.

Ubuntu 10.10 on Oracle VM VirtualBox 4.0.4 – Quick Tips

April 4, 2011 Leave a comment

Ubuntu 10.10 has tons of new built-in features with better look and feel, so if you’re using older versions, its  worth to upgrade.

If you have not installed or worked much in Ubuntu before, here are some quick tips… Here you go!
(1) How to make Ubuntu Full Screen?
(2) How to add new users in Ubuntu?
(3) How to install Perl Modules through CPAN on Ubuntu?

How to make Ubuntu Full Screen?

If you google it, many posts may come up, but this link I found to be more simple and straightforward! When you install “VirtualBox Guest Additions” following those steps and restart the VirtualBox, automatically you would see the screen becoming fullscreen in Ubuntu.

Go to Top

How to add new users in Ubuntu?

admin@ubuntu-VirtualBox:/$ sudo adduser ubuntu_user
Adding user `ubuntu_user’ …
Adding new group `ubuntu_user’ (1001) …
Adding new user `ubuntu_user’ (1001) with group `ubuntu_user’ …
Creating home directory `/home/ubuntu_user’ …
Copying files from `/etc/skel’ …
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for ubuntu_user
Enter the new value, or press ENTER for the default
Full Name []: Ubuntu User
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y

Go to Top

How to install Perl Modules through CPAN on Ubuntu ?

(1) Run sudo  apt-get install build-essential in ubuntu terminal to install all required packages for CPAN
(2) Run perl -MCPAN -e shell to invoke cpan command
(3) Now you can install any perl module using cpan> install < Module name >

(A) Installing CGI::Application Framework on Ubuntu

You can either install through CPAN or installing the package libcgi-application-plugins-perl as below.

admin@ubuntu-VirtualBox:~/cgi-bin$ sudo apt-get install libcgi-application-plugins-perl
[sudo] password for admin:
Reading package lists… Done
Building dependency tree
Reading state information… Done

Go to Top

Categories: Ubuntu Tags: , , ,

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: ,