Home / Interview / Perl :: General Questions

Interview :: Perl

41) What is the difference between use and require in Perl?

Use: It is used only for the Perl modules. The included modules are verified at the time of compilation. It does not need the file extension.

Require: It is used for both Perl modules and libraries. The included objects are verified at runtime. It does need the file extension.

42) How many loop control keywords are there in Perl?

There are three types of loop control statement:

  • Next
  • Last
  • Redo
43)

What does next statement do in Perl?

Perl next statement is like continue statement in C. It lets you move on to the next element of your array or hash skipping all elements in between.

44)

What does last statement do in Perl?

Perl next statement is like break statement in C. It exists the loop immediately skipping remaining codes.

45)

What does redo statement do in Perl?

Perl redo statement restarts the current loop without evaluation of the control statement.

46) Define operators used in Perl?

A Perl operator is a series of symbols like +, -, =, <, >, etc. It uses its operands as arguments.

  • Pattern matching operator : (=~, !~)
  • Shifting operator : (>>, <<)
  • Comparison operator : (==, !=, <=, >=, <=>)
  • Logical operator : &&, ||
47) What is the importance of Perl warnings?

Perl warnings help us to check errors in our code by giving warnings.

To enable them use -w :

Alternatively, you can also supply it within the "shebang" line:

48)

Why do we use "use strict" in Perl?

The "use strict" command in Perl calls strict pragma. This pragma helps to catch some bugs or errors in our script and stops the program execution.

49) What are Perl strings?

Strings are an essential part of Perl. They are scalars, so they start with $ sign. Strings can be placed inside single or double quote.

Two types of string operators are there:

  • Concatenation (.)
  • Repetition (x)
50) What is an interpolation in Perl?

Interpolation means inserting something with different nature. It can be defined as replacing a variable with its value.