Perl Tutorial

Log Effectively Using Custom Perl Logger Module

by Balakrishnan Mariyappan on July 29, 2010

For any custom written user services and processes, you should maintain a log file to view the status of the service, or to troubleshoot any issues with the services/processes.

Perl CPAN offers few modules which provides the automated object interface for handling logging for services.

In this article, let us write our own Perl logger module which internally uses Perl CPAN modules: Log::Agent, Log::Agent::Driver::File and Log::Rotate.

This custom perl logger module will perform the following operations.
(more…)

{ 1 comment }

How To: Perl TCP / UDP Socket Programming using IO::Socket::INET

by Balakrishnan Mariyappan on July 1, 2010

In this article, let us discuss how to write Perl socket programming using the inbuilt socket modules in Perl.

Perl socket modules provides an object interface that makes it easier to create and use TCP / UPD sockets.

This article covers the following topics:

  • Perl example code for TCP client and server
  • Perl example code for UDP client and server
  • Read and write descriptor list using Select(IO::Select)

(more…)

{ 6 comments }

Perl Exporter Tutorial with Examples – @EXPORT and @EXPORT_OK

by Balakrishnan Mariyappan on June 24, 2010

Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access it’s members.
(more…)

{ 5 comments }

How to do Perl Hash Reference and Dereference

by Balakrishnan Mariyappan on June 18, 2010

Question: How do I reference perl hash? How do I deference perl hash? Can you explain it with a simple example?

Answer: In our previous article we discussed about Perl array reference. Similar to the array, Perl hash can also be referenced by placing the ‘\’ character in front of the hash. The general form of referencing a hash is shown below.
(more…)

{ 2 comments }

Perl Array Reference and Dereference Tutorial With Practical Examples

by Balakrishnan Mariyappan on June 17, 2010

In this article let us review how to reference and dereference Perl array with examples. Reference is nothing but the location ( address ) of another variable. The references can be of array, or hash, or a snippet of Perl code. References makes the Perl code to run faster.
(more…)

{ 2 comments }

8 Awesome Perl Command Line Arguments You Should Know

by Balakrishnan Mariyappan on June 10, 2010

Command line options in Perl could be useful to do smaller tasks effectively.

In this article, let us review how to use Perl command line options to do the following tasks:

  • Edit file content
  • Handle line separator
  • Check syntax errors
  • Load modules
  • Perform looping
  • Execute perl code
  • Set input line separator
  • Split the input line
  • etc.,

(more…)

{ 5 comments }

Perl eval built-in function is very powerful. In this article let us review how to use regex in eval, trapping errors using eval, create dynamic code using eval, insert a code from a file/sub-routine using eval etc.,

The general form of perl eval expects a expression or a block of code as an argument.
(more…)

{ 4 comments }

Perl Tutorial for BeginnersIf you are a Linux sysadmin who writes occasional perl code (or) a developer who wants to learn perl program language, these 20 basic perl programming tips and tricks explained in this article will give you a jumpstart.

(more…)

{ 3 comments }