Categories

Perl Interview Questions and Answers

Here are Perl interview questions and answers for freshers as well as experienced candidates to get their dream job.

1. What is Perl?

Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl is a term stands for “Practical Extraction and Reporting Language” even though there is no acronym for Perl. It was introduced by Larry Wall in 1987. Perl language was specially designed for text editing.

2. Where is Perl used?

The power of Perl scripting language can be implemented in many fields. The most popular use of Perl is in Web development., Perl is also used to automate many tasks in the Web servers, and other administration jobs, it can automatically generate emails and clean up systems.

3. There are 3 Types of variables:

1) Scalars

2) Arrays

3) Hashes

4. What is Perl Array?

An Array is a special type of variable which stores data in the form of a list; each element can be accessed using the index number which will be unique for each and every element. You can store numbers, strings, floating values, etc. in your array. This looks great, So how do we create an array in Perl? In Perl, you can define an array using ‘@’ character followed by the name that you want to give. Let’s consider defining an array in Perl.

5. What is Dynamic Array?

Dynamic arrays are those that you declare without specifying any value on them. So when exactly do we store values in that array? Simple, we store them during run time.

6. what is Push, Pop, shift, unshift for Perl arrays ?

Perl Push:
adds array element at the end of an existing array.

Perl Pop: removes the last element from an array.

Perl Shift: removes the first element from an array.

Perl Unshift: adds an element at the beginning of an array.

7. What are Hashes?

A hash can also hold as many scalars as the array can hold. The only difference is we don’t have any index rather we have keys and values. A hash can be declared, starting with % followed by the name of the hash.

8. What is Perl Delete key

delete $newHash{'Jim'};#This will delete an entry from the hash.

9. What is perl Operator?

Operators in computer language indicate an action that can be performed on some set of variables or values which computer can understand. Perl has incorporated most of the Operators from C language. Perl has many operators compared with other programming languages. Operators are categorized as Arithmetic, Logical, relational and assignment operators.

1) Arithmetic Operators:

2) Assignment Operators:

3) Logical and Relational Operators:

4)

10. What is Perl Special Variables?

Special variables in Perl are those who have some predefined meaning. These variables denoted with either real Name or Punctuation symbols. We have a special variable for all the Perl supported Variables like scalar special variables, Array special variables, hash special variables. Most of the special variables that we use are of scalars.

11. What is Regular Expression?

Perl regular expression is strong enough in matching the string patterns within a statements or group of statements. Regular expressions are mostly used in text parsing, pattern matching and much more based on the requirement. We have certain operators, which are specially used by regular expression pattern binding =~ and !~, These are test and assignment operators.

12. What is perl Subroutine?

Subroutines are similar to functions in other programming languages. We have already used some built-in functions like print, chomp, chop, etc. We can write our own subroutines in Perl. These subroutines can be written anywhere in the program; it is preferable to place the subroutines either at the beginning or at the end of the code.

13. What is an Exception?

An exception is an event that occurs during the program execution which will suspend or terminate your program.

14. What is perl socket?

The socket is a medium through which two computers can interact on a network by using network address and ports.

Suppose, A (Server) and B (Client) are two systems, which has to interact with each other using Sockets for running some programs.

To implements this we need to create sockets in both A (Server) and B (Client), A will be in the receiving state and B will be in the sending state.

15. What is Perl Modules and Packages ?

Modules and Packages are closely related to each other and are independent. Package: A Perl package is also known as namespace and which have all unique variables used like hashes, arrays, scalars, and subroutines. Module: Module is a collection of reusable code, where we write subroutines in it. These modules can be loaded in Perl programs to make use of the subroutines written in those modules.