Perl for Beginners at BarCamp Delhi

Yesterday at BarCamp Delhi Prateek and Pratul decided to hold a hack-a-thon. The idea being, that in 2 to 3 hours, the group of programmers assembled would hack together some application. Some of the ideas thrown around were:

  • A Firefox Plugin
  • A Firefox Greasemonkey Extension
  • A manufacturing, logistical support web app

Pratul and Prateek probably have a more complete list than I do. The hack-a-thon broke apart into a few groups, each doing something different. No applications were built but a few Windows programmers were interested enough that I spent about 20 minutes showing them a few “Hello World” Perl scripts.

I’ve attached the Perl scripts for the folks who asked for them and any others that might be interested. Also, if anyone is interested in learning Perl, I highly recommend this book. It says 21 days to learn Perl but most of you will probably pick it up in less than a week.

Unfortunately, the extensions of the files are being changed to .txt so please take off the .txt once you download the files. I’m also putting the scripts inline. A simple Hello World script

#! /usr/bin/perl

use warnings;
use strict;

my $name = "Pankaj";
print "Hello $name.n"; A “Hello World” script that uses a very simple Perl module (below)

#! /usr/bin/perl

use warnings;
use strict;

use lib("../lib");
use Hello;

my $name = "Pankaj";

Please put the in a relative path to where you put as described in “use lib” line above in Our very simplistic Perl module

package Hello;

sub new {

sub hello{
my $name = $_[0];
print "hello " . $name;
} #
# ------------------------------------------------------------

And our final example that one of the campers asked for was a Perl script that would take input from the command line interactively. Our final “Hello World” script that interactively asks for names on the command line.

#! /usr/bin/perl

use warnings;
use strict;
use Getopt::Long;
use Term::ReadLine;

my $foo;
my @bar;

GetOptions("foo=i" => $foo);

my $count = 0;
my $term = Term::ReadLine->new();

while ($count readline("What is your name? ");
$bar[$count] = $line;

foreach my $f (@bar) {

print "bar is $fn";

We didn’t get to it but would one of the campers like to take one of these scripts and turn them into a CGI script or a mod_perl application? Please post your changes in a comment to this post.

Related Posts:

The Financial Crisis and India

BarCamp Delhi has been going on this weekend. I don’t think anyone took any video of the presentation but I turned into a bit of a pig and took up three speaking slots.

Sorry to Netra, Sukhdeep and every one else for taking up their slots!

The presentation is available as a download below as well as on Slideshare.

So far, there are posts on BarCampDelhi5 coverage on Webyantra and the BarCampDelhi Blog.

Related Posts: