Interview :: 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.
There are three types of loop control statement:
- Next
- Last
- Redo
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.
What does last statement do in Perl?
Perl next statement is like break statement in C. It exists the loop immediately skipping remaining codes.
What does redo statement do in Perl?
Perl redo statement restarts the current loop without evaluation of the control statement.
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 : &&, ||
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:
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.
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)
Interpolation means inserting something with different nature. It can be defined as replacing a variable with its value.