Perl Interview Questions And Answers

perl interview questions and answers   Top 24 Perl Interview Questions And Answers

1) What is the full form of PERL?

Its 'Practical Extraction and Report Language'


2) What is Perl?

It's a programming language used for system admin, web development, network programming, GUI development and many more.
● It is cross platform programming language.
● It is used for critical projects.
● It is open source language.
● It came from unix family.


3) What are the different features of Perl?

Following are the different features of Perl:
● Perl's database interface DBI supports multiple databases like oracle, Sybase, mysql etc.
● It work well with different markup languages.
● It supports unicode.
● It supports both procedural and object oriented programming.
● It is extensible.


4) Why Perl is known as the Duct tape of the internet?

It is known as the duct tape of the internet as it provides quick and easy fixes to the data problems.


5) Why Perl is the Interpreted Language?

Code can be run as is without compilation state and creates non portable executable program.


6) What does -d option signifies for perl command?

It runs the program in debug mode.


7) How to invoke the interpreter for perl command line program?

Here is the way to invoke the interpreter for perl program.

C:>perl script.pl


8) How to write comments in perl program?

There are multiple ways to write the comments in perl program which would be helpful for the developers.
Single line comment - # would be use for single line comment
Multiline comments - These comments start with = and then ends with =cut


9) What are the different datatypes in Perl?

Following are the different datatypes in Perl:

● Scalar - These are simple variables. They start with dollar sign $
● Arrays - These are ordered list. They start with at @
● Hashes - These are key/value pairs. They starts with percent sign %

Examples:


Scalar:
$var = 12;
$var = 'abc';

Arrays:
@arr = (22,65,6,11);

Hashes:
%var = ('a',1,'b',2);


10) What is variable context in Perl?

It treats variables differently based on the context.

Example:


@arr = (22,65,6,11);
@cp = @arr;
$count = @arr;


11) What is the use of special variable $[ in Perl?

This special variable resets the indexes of the defined arrays.


12) In Perl, what are the subroutines?

These are the group of statement that together perform tasks.Example:

sub subroutine_name { body of the subroutine }


13) In Perl, what are the formats?

Perl has the writing template called as format. These are being used to output the reports.

Syntax:


format FormatName =
fieldline
value_one, value_two, value_three
fieldline
value_one, value_two
.


14) What are the fieldholders in Perl?

These are used to hold spaces for data which can be placed later.

Syntax:


@<<<<
.


15) How to define the report header in Perl?

The report header can be defined using $^ or $FORMAT_TOP_NAME variable.


16) What are the different file handles in Perl?

Following are the different file handles in Perl:
● STDIN - standard input
● STDOUT - standard output
● STDERR - standard error


17) What is the PERMS in Perl?

These are the parameters which specify the file permission.


18) In Perl, what is the default value of PERMS?

By default it takes 0x666


19) In Perl, how to return current position of the directory?

Here is the standard function used to return current position of the dir.
telldir DIRHANDLE


20) In Perl, what is the CARP function?

This function is the equivalent of warn print the message to STDERR.

function {
   carp "Error in module!";
}


21) In Perl, what is the cluck function?

This is similar to carp function but prints stack trace of the complete module.


22) In Perl, what is the croak function?

This is similar to die function, except it reports the details one level up.


23) In Perl, what is the confess function?

This is similar to cluck function, it calls die and then print complete stack trace.


24) In Perl, which of these is not the global scalar variable?

a. $EVAL_ERROR
b. $_
c. $^L
d. %ENV

Answer is d

%ENV - this is global hash special variable which specify the current environment details.