Wednesday, April 25, 2018

Writing Client-Server Applications using IO::Socket


You should now know what a client and server program is. Simply put, a client requests a service and a server services the request. There are several ways to do this. The crudest will be to call a program within perl and pass the parameters during the call. Another way is to use pipes. A program can call another program but the input to the called program will be passed through the STDIN of the other program. Both methods are crude and allow only for simple passing of input and output. Another way to do this is using sockets.

Sockets allow two programs to communicate with each other. The server binds a port on the machine. The client connects to that port to communicate with the server

Writing Client-Server Applications in Perl: Introduction


The traditional architecture for applications is the stand-alone architecture. With this, all components of an application is executed in one giant program. This is ok if the application is meant to be used by one person on one machine at a time.

With the changes in technology AND business processes, this architecture has to change. We see several users now using the same application at the same time accessing the same database(s).
Obviously, this architecture has to change to accomodate changes in the way applications are used.

Wednesday, April 30, 2014

Parsing HTML Pages using HTML::Parser

Introduction to HTML::Parser

There are times when you will need to read an HTML file and extract a field from that file. Perl has a module called HTML::Parser that simplifies this task.

This module reads an HTML file and allows you to define actions when it reads a starting tag, the body and the end tag. To do this, you can define subroutines that are to be executed during these events. The HTML::Parser documentation lists all the events that can happen during processing. For our discussion, we will discuss only the starttext and end events.

Perl Packages

Introduction to Perl Packages

Perl has a feature that allows you to package sets of code into its own package. You use packages to group subroutines so that these can be re-useable or to "isolate" variables used in a subroutine from other subroutines. This isolation of variables is one of the features to implement object oriented programming in Perl.

Thursday, August 8, 2013

Multi-Dimensional Hashes in Perl

Introduction To Hashes

Perl hashes are data types that allow you to associate data to a key. For example, a hash can store article titles with the date of publication as the key:

%hash = (20030227 => 'Multi-dimensional hashes',
         20030113 => 'Introduction to mod_perl',
         20021201 => 'The CPAN Module'

This is a one-dimensional hash.

Wednesday, August 7, 2013

Multi-Dimensional Arrays in Perl

Introduction to Arrays

A Perl array is a data type that allows you to store a list of items. You create them by assigning them to an array variable. The array variable is identified by a @ prefix. To define a list of dates, we do this:

@array = ('20020701', '20020601', '20020501');
This is a one-dimensional array.

Tuesday, August 6, 2013

Formatting Numbers in Perl

Introduction to Formatting Numbers 

Let us say that your program is calculating a number in decimal and you needed to print out leading zeros to it, how would you do it? If there is no need for formatting, you can just use the print command. 

my $a = 10.003403; print "$a";