Category: 09. Perl

  • Date and Time

    This chapter will give you the basic understanding on how to process and manipulate dates and times in Perl. Current Date and Time Let’s start with localtime() function, which returns values for the current date and time if given no arguments. Following is the 9-element list returned by the localtime function while using in list context − Try the…

  • Operators

    What is an Operator? Simple answer can be given using the expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and + is called operator. Perl language supports many operator types, but following is a list of important and most frequently used operators − Lets have a look at all…

  • Loops

    There may be a situation when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop…

  • Perl Conditional Statements – IF…ELSE

    Perl conditional statements helps in the decision making, which require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined…

  • Hashes

    A hash is a set of key/value pairs. Hash variables are preceded by a percent (%) sign. To refer to a single element of a hash, you will use the hash variable name preceded by a “$” sign and followed by the “key” associated with the value in curly brackets.. Here is a simple example of using…

  • Arrays

    An array is a variable that stores an ordered list of scalar values. Array variables are preceded by an “at” (@) sign. To refer to a single element of an array, you will use the dollar sign ($) with the variable name followed by the index of the element in square brackets. Here is a…

  • Scalars

    A scalar is a single unit of data. That data might be an integer number, floating point, a character, a string, a paragraph, or an entire web page. Here is a simple example of using scalar variables − This will produce the following result − Numeric Scalars A scalar is most often either a number…

  • Variables

    Variables are the reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can…

  • Data Types

    Perl is a loosely typed language and there is no need to specify a type for your data while using in your program. The Perl interpreter will choose the type based on the context of the data itself. Perl has three basic data types: scalars, arrays of scalars, and hashes of scalars, also known as…

  • Syntax Overview

    Perl borrows syntax and concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, Lisp and even English. However, there are some definite differences between the languages. This chapter is designd to quickly get you up to speed on the syntax that is expected in Perl. A Perl program consists of a sequence of declarations…