PERL Articles

Page 14 of 15

Creating Hashes in Perl

Mohd Mohtashim
Mohd Mohtashim
Updated on 29-Nov-2019 239 Views

Perl Hashes are created in one of the two following ways. In the first method, you assign a value to a named key on a one-by-one basis −$data{'John Paul'} = 45; $data{'Lisa'} = 30; $data{'Kumar'} = 40;In the second case, you use a list, which is converted by taking individual pairs from the list: the first element of the pair is used as the key, and the second, as the value. For example −%data = ('John Paul', 45, 'Lisa', 30, 'Kumar', 40);For clarity, you can use => as an alias for, to indicate the key/value pairs as follows −%data = ...

Read More

How to create Array in Perl?

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 291 Views

Perl Array variables are prefixed with the @ sign and are populated using either parentheses or the qw operator. For example −@array = (1, 2, 'Hello'); @array = qw/This is an array/;The second line uses the qw// operator, which returns a list of strings, separating the delimited string by white space. In this example, this leads to a four-element array; the first element is 'this' and last (fourth) is 'array'. This means that you can use different lines as follows −@days = qw/Monday Tuesday ... Sunday/;You can also populate an array by assigning each value individually as follows −$array[0] = 'Monday'; ... $array[6] = 'Sunday';

Read More

Creating Variables in Perl

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 240 Views

Perl variables do not have to be explicitly declared to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.Keep a note that this is mandatory to declare a variable before we use it if we use strict statement in our program.The operand to the left of the = operator is the name of the variable, and the operand to the right of the = operator is the value stored in the variable. For example −$age = 25;             ...

Read More

What are Perl Numerical Literals?

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 421 Views

Perl stores all the numbers internally as either signed integers or double-precision floating-point values. Numeric literals are specified in any of the following floating-point or integer formats −TypeValueInteger1234Negative integer-100Floating point2000Scientific notation16.12E14Hexadecimal0xffffOctal0577

Read More

What are different Perl Data Types?

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 363 Views

Perl is a loosely typed language and there is no need to specify a type for your data while using it 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 associative arrays. Here is a little detail about these data types.Sr.No.Types & Description1ScalarScalars are simple variables. They are preceded by a dollar sign ($). A scalar is either a number, a string, or a reference. A reference is actually an address of a variable, which ...

Read More

What is Perl Identifiers?

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 732 Views

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 designed to quickly get you up to speed on the syntax that is expected in Perl.A Perl program consists of a sequence of declarations and statements, which run from the top to the bottom. Loops, subroutines, and other control structures allow you to jump around within the code. Every simple statement must end with a semicolon (;).A Perl identifier is a name used to identify a variable, function, class, module, ...

Read More

Perl File Extension

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 3K+ Views

Perl is a general-purpose programming language originally developed for text manipulation and now used for a wide range of tasks including system administration, web development, network programming, GUI development, and more.A Perl script can be created inside of any normal simple-text editor program. There are several programs available for every type of platform. There are many programs designed for programmers available for download on the web.As a Perl convention, a Perl file must be saved with a .pl or.PL file extension in order to be recognized as a functioning Perl script. File names can contain numbers, symbols, and letters but ...

Read More

How to run Perl Program?

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 10K+ Views

The following are the different ways to start Perl.Interactive InterpreterYou can enter Perl and start coding right away in the interactive interpreter by starting it from the command line. You can do this from Unix, DOS, or any other system, which provides you a command-line interpreter or shell window.$perl -e               # Unix/Linux or C:>perl -e             # Windows/DOSHere is the list of all the available command-line options −Sr.No.Option & Description1-d[:debugger]Runs program under a debugger2-IdirectorySpecifies @INC/#include directory3-TEnables tainting checks4-tEnables tainting warnings5-UAllows unsafe operations6-wEnables many useful warnings7-WEnables all ...

Read More

Perl Installation on Macintosh Platform

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 414 Views

In order to build your own version of Perl, you will need 'make', which is part of the Apple developer tools usually supplied with Mac OS install DVDs. You do not need the latest version of Xcode (which is now charged for) in order to install make.Here are the simple steps to install Perl on Mac OS X machine.Open a Web browser and go to https://www.perl.org/get.html.Follow the link to download the zipped source code available for Mac OS X.Download the perl-5.x.y.tar.gz file and issue the following commands at $ prompt.$tar -xzf perl-5.x.y.tar.gz $cd perl-5.x.y $./Configure -de $make $make test $make ...

Read More

Perl Installation on Unix and Linux Platform

Mohd Mohtashim
Mohd Mohtashim
Updated on 28-Nov-2019 1K+ Views

Here are the simple steps to install Perl on Unix/Linux machine.Open a Web browser and go to  https://www.perl.org/get.html.Follow the link to download the zipped source code available for Unix/Linux.Download the perl-5.x.y.tar.gz file and issue the following commands at $ prompt.$tar -xzf perl-5.x.y.tar.gz $cd perl-5.x.y $./Configure -de $make $make test $make installNOTE − Here $ is a Unix prompt where you type your command, so make sure you are not typing $ while typing the above-mentioned commands.This will install Perl in a standard location /usr/local/bin and its libraries are installed in /usr/local/lib/perlXX, where XX is the version of Perl that you ...

Read More
Showing 131–140 of 146 articles
Advertisements