≡ Menu

Perl Tutorial

Log Effectively Using Custom Perl Logger Module

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 [...]

{ 1 comment }

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

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 [...]

{ 10 comments }

Perl Exporter Tutorial with Examples – @EXPORT and @EXPORT_OK

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. @EXPORT and @EXPORT_OK are the two main variables used during export operation. @EXPORT contains list of symbols (subroutines and variables) of [...]

{ 11 comments }

How to do Perl Hash Reference and Dereference

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 [...]

{ 5 comments }

Perl Array Reference and Dereference Tutorial With Practical Examples

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. Perl Reference To Array Normally, we [...]

{ 12 comments }

8 Awesome Perl Command Line Arguments You Should Know

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 [...]

{ 7 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. 1. [...]

{ 5 comments }

If 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. 1. List all Installed Perl Modules from Unix Command Line Get a list of all installed perl [...]

{ 4 comments }