Perl interview questions part 2/Perl Interview Questions and Answers for Freshers & Experienced

What Is A Short Circuit Operator?

The C-Style operator, ll, performs a logical (or) operation and you can use it to tie logical clauses together, returning an overall value of true if either clause is true. This operator is called a short-circuit operator because if the left operand is true the right operand is not checked or evaluated.

Posted Date:- 2021-09-06 04:03:43

How Do You Connect To Database In Perl

There is DBI module. use DBI;my $dbh = DBI->connect('dbi:Oracle:orcl', 'username', 'password',)where username and password is yours. This is example for oracle database.

For Sybase:
use DBI;
my $dbh = DBI->connect('dbi:Sybase:server=$SERVER', 'username', 'password')

Posted Date:- 2021-09-06 04:02:54

What Is Meant By A 'pack' In Perl?

<> Pack Converts a list into a binary representation
<> Takes an array or list of values and packs it into a binary structure, returning the string containing the structure
<> Hope that kills the problem

Posted Date:- 2021-09-06 04:01:45

What Is A Datahash(). What Does It Mean? And For What Purpose It Is Used??

In Win32::ODBC, DataHash() function is used to get the data fetched through the sql statement in a hash format.

Posted Date:- 2021-09-06 04:00:25

Explain the use of –I, -n, and –p options?

Among all the options, -n and –p is used to include scripts within the loop. The first option is used to enables the programming language to implement the script inside the loop. The –p options function in the same manner with the addition of continuation. The –i option is used to change the files in the right place. Using this option, the name of the input file can be changed, and the output file would open with the original file name. With this option, no backup of any file is created.

Posted Date:- 2021-09-06 03:57:41

Explain what is Perl one liner?

One liner is one command line programs and can be executed from the command line immediately.

For example,

# run program under the debugger

perl-d my_file

Posted Date:- 2021-09-06 03:56:35

Explain what is STDIN, STDOUT and STDERR?

>> STDIN: The STDIN file handle is used to read from the keyboard.

>> STDOUT: It is used to write into the screen or another program.

>> STDERR: It is also used to write into a screen. STDERR is a standard error stream that is used in Perl.

Posted Date:- 2021-09-06 03:55:45

Mention what are the two ways to get private values inside a subroutine or block?

There are two ways through which private values can be obtained inside a subroutine or block

<> Local Operator: On global variables only this operator can operate. The value of the private variable is saved on the Local Operator and makes the provision to restore them at the end of the block

<> My Operator: To define or create a new variable this operator can be used. Variable that is created by My Operator will always be declared private to block inside which it is defined.

Posted Date:- 2021-09-06 03:54:38

How Do You Work With Array Slices?

An array slice is a section of an array that acts like a list, and you indicate what elements to put into the slice by using multiple array indexes in square brackets. By specifying the range operator you can also specify a slice.

Posted Date:- 2021-09-06 03:52:47

What Are The Three Ways To Empty An Array?

The three different ways to empty an array are as follows
1) You can empty an array by setting its length to a negative number.
2) Another way of empting an array is to assign the null list ().
3) Try to clear an array by setting it to undef, but be aware when you set to undef.

Posted Date:- 2021-09-06 03:51:48

How many loop control keys are found and what do they connote?

In this language, there are three types of loop control statements namely next, redo, and last.

1. Next statement – It is similar to the continue statement in C language and helps to move to the next element of an array skipping all the elements in between.
2. Redo statement – It helps to restart the current loop without considering the control statement.
3. Last statement – It functions similar to that break statement in C language. It helps to exit the loop soon after using the statement.

Posted Date:- 2021-09-06 03:50:53

What does Perl array function mean?

In an array, this function is used to add or remove elements. This function is available in four different types, they are

1. Pop – It helps to remove the last element of an array.
2. Push – This function helps to add a new element at the end of an array.
3. Shift – this function helps to remove the element on the extreme left of an array.
4. Unshift – To add a new element at the start of an array, this function is used.

Posted Date:- 2021-09-06 03:50:07

Explain what is Polymorphism in Perl?

In Perl, Polymorphism means the methods defined in the base class will always over-ride the methods defined in the parent class.

Posted Date:- 2021-09-06 03:49:22

Explain what is Chop & Chomp function does?

<> Chop function eliminates the last character from expr, each element of the list

<> Chomp function eliminates the last character from an expr or each element of the list if it matches the value of $/. It is considered better than chop as it only removes the character if there is a match.

Posted Date:- 2021-09-06 03:48:36

Mention how many ways you can express string in Perl?

You can express string in Perl in many ways

For instance “this is guru99.”

<> qq/this is guru99 like double quoted string/
<> qq^this is guru99 like double quoted string^
<> q/this is guru99/
<> q&this is guru99&
<> q(this is guru99)

Posted Date:- 2021-09-06 03:47:35

Explain what is the scalar data and scalar variables in Perl?

Scalar in Perl means a single entity like a number or string. So, the Java concept of int, float, double and string equals to perls scalar and the numbers and strings are exchangeable. While scalar variable is used to store scalar data. It uses $ sign and followed by one or more alphanumeric characters or underscore. It is a case sensitive.

Posted Date:- 2021-09-06 03:46:21

How can you call a subroutine and identify a subroutine?

‘&myvariable’ is used to call a sub-routine and ‘&’ is used to identify a sub-routine.

Posted Date:- 2021-09-06 03:43:44

“Perl regular expressions match the longest string possible”. What is the name of this match?

It is called as “greedy match” because Perl regular expressions normally match the longest string possible.

Posted Date:- 2021-09-06 03:42:59

What are the advantages of c over Perl?

There are more development tools for C than for PERL. PERL execute slower than C programs. Perl appears to be an interpreted language but the code is complied on the fly. If you don’t want others to use your Perl code you need to hide your code somehow unlike in C. Without additional tools it is impossible to create an executable of a Perl program.

Posted Date:- 2021-09-06 03:42:24

In CPAN module, name an instance you use.

In CPAN, the CGI and DBI are very common packages

Posted Date:- 2021-09-06 03:41:50

How can memory be managed in Perl?

Whenever a variable is used in Perl, it occupies some memory space. Since the computer has limited memory the user must be careful of the memory being used by the program. For Example:

use strict;


my @lines = <IN>



foreach (@lines)


print OUT m/([^s]+)/,"



Posted Date:- 2021-09-06 03:41:03

Why Perl aliases are considered to be faster than references?

In Perl, aliases are considered to be faster than references because they do not require any dereferencing.

Posted Date:- 2021-09-06 03:40:06

How can information be put into hashes?

When a hash value is referenced, it is not created. It is only created once a value is assigned to it. The contents of a hash have no literal representation. In case the hash is to be filled at once the unwinding of the hash must be done. The unwinding of hash means the key value pairs in hash can be created using a list, they can be converted from that as well. In this conversion process the even numbered items are placed on the right and are known as values. The items placed on the left are odd numbered and are stored as keys. The hash has no defined internal ordering and hence the user should not rely on any particular ordering.

Posted Date:- 2021-09-06 03:39:32

Can Perl patterns be considered as regular expressions?

The answer mentioned above is no, the Perl patterns cannot be considered as regular expressions since the patterns do not have any references. The regular expression should determine the next state automation and also keep the previous state into it. The wrong usage of a pattern is disqualified regular expressions.

Posted Date:- 2021-09-06 03:38:38

Explain the difference between Perl hash and Perl array?

Perl hash is an unordered list of elements where is used by the key values. It is symbolized by a % sign.

Perl array is an ordered list of elements used in the programming language which are used by index numbers and symbolized by @ sign.

Posted Date:- 2021-09-06 03:38:05

) How many types of primary data structures are there? What do they denote?

There are three types of primary data structure in this programing language. They are arrays, the scalar, associative arrays.

1. Arrays – It is denoted with ‘@’ a sign.
2. Scalar – It is capable of holding one information at one time, and it is denoted by the $ symbol. Further, this symbol is followed by a Perl identifier that can be in the form of underscores or alphanumeric. It should not start with a digit.
3. Associative arrays – These are also called hashes which work similarly to that of hash tables used by programmers in other languages.

Posted Date:- 2021-09-06 03:37:13

How can you replace the characters from a string and save the number of replacements?


use strict;

use warnings;

my $string="APerlAReplAFunction";

my $counter = ($string =~ tr/A//);

print "There are $counter As in the given string

print $string;

Posted Date:- 2021-09-06 03:36:39

Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.

for ($count = 10; $count >= 1; $count--)


print "$count ";


Posted Date:- 2021-09-06 03:36:04

How can you use Perl warnings and what is the importance to use them?

The Perl warnings are those in which Perl checks the quality of the code that you have produced. Mandatory warnings highlight problems in the lexical analysis stage. Optional warnings highlight cases of possible anomaly.

use warnings; # it is same as importing "all"

no warnings; # it is same as unimporting "all"

use warnings::register;

if (warnings::enabled()) {

warnings::warn("any warning");


if (warnings::enabled("void")) {

warnings::warn("void", "any warning");


Posted Date:- 2021-09-06 03:35:26

What is the usage of -i and 0s options?

The -i option is used to modify the files in-place. This implies that Perl will rename the input file automatically and the output file is opened using the original name. If the -i option is used alone then no backup of the file would be created. Instead -i.bak causes the option to create a backup of the file.

Posted Date:- 2021-09-06 03:34:35

What kind of data is supported by this programming language?

There are three types of data namely – arrays of scalars, scalars, and hashes of scalars.

Posted Date:- 2021-09-06 03:33:59

What Perl identifier connotes?

The identifier is used to state a variable, module, class, function, and other relating objects while using this programming language. The variable starts with symbols such as @, %, or $ which is followed by digits and underscore.

Posted Date:- 2021-09-06 03:33:27

Is There Any Way To Add Two Arrays Together?

Of course you can add two arrays together by using push function. The push function adds a value or values to the end of an array. The push function pushes the values of list onto the end of the array. Length of an array can be increased by the length of list.

Posted Date:- 2021-09-06 03:32:44

Explain About Typeglobs?

Type globs are another integral type in perl. A typeglob`s prefix derefrencer is *, which is also the wild card character because you can use typeglobs to create an alias for all types associated with a particular name. All kinds of manipulations are possible with typeglobs.

Posted Date:- 2021-09-06 03:32:07

Explain About An Ivalue?

An ivalue is an item that can serve as the target of an assignment. The term I value originally meant a “left value”, which is to say a value that appears on the left. An ivalue usually represents a data space in memory and you can store data using the ivalues name. Any variable can serve as an ivalue.

Posted Date:- 2021-09-06 03:31:26

Name All The Prefix Dereferencer In Perl?

The symbol that starts all scalar variables is called a prefix dereferencer. The different types of dereferencer are.
(i) $-Scalar variables
(ii) %-Hash variables
(iii) @-arrays
(iv) &-subroutines
(v) Type globs-*myvar stands for @myvar, %myvar.

Posted Date:- 2021-09-06 03:31:00

Does Perl programming has objects or not?

The answer to this question is yes, this programming language has objects that do not force to use it. In most cases, object-oriented modules can be used without even understanding the object. But if the program is a large one, then it is required to make it subject-oriented.

Posted Date:- 2021-09-06 03:30:25

Name All The Prefix Dereferencer In Perl?

Any variable during the coding with My statement remains in the current block. The variable along with the value goes out of the block. On the contrary in the case of the Local statement, it is used to assign any value to a global variable outside the block. The variable of the local statement can be used globally, but the value lasts till it is inside the block.

Posted Date:- 2021-09-06 03:29:57

Draw a difference between My and Local?

Any variable during the coding with My statement remains in the current block. The variable along with the value goes out of the block. On the contrary in the case of the Local statement, it is used to assign any value to a global variable outside the block. The variable of the local statement can be used globally, but the value lasts till it is inside the block.

Posted Date:- 2021-09-06 03:28:40

What is the “grep” function in Perl?

The grep function in Perl is mainly used for Pattern matching as in other scripting languages.

The “grep” function works on a list. It evaluates an expression or a block for each element of the List. For each statement that returns true as a result of evaluating an expression, it adds that element to the list of returning values.

Look at the following code snippet:

@list = (“foo”,10,0,”bar”,20);
@has_string = grep( /s/,@list );
Print “@has_string
Output: foo bar

The above code executes the “grep” command on a list and matches the pattern string (/s) to the list. The output is only the elements that are a string.

Posted Date:- 2021-09-06 03:28:17

Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?

@arraycontent=('ab', 'cd', 'ef', 'gh')

foreach (@arraycontent)


print "$_


Posted Date:- 2021-09-06 03:27:28

Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?

The command line arguments in Perl are stored in an array @ARGV.

$ARGV[0] (the first argument)

$ARGV[1] (the second argument) and so on.

$#ARGV is the subscript of the last element of the @ARGV array, so the number of arguments on the command line is $#ARGV + 1

Posted Date:- 2021-09-06 03:27:00

State the difference between Use and Require?

Both Use and require are used for importing modules and file extension is not required for any of them.

In case of use, the objects included are different at the time of compilation, and in case of require, the objects are verified during the runtime.

Posted Date:- 2021-09-06 03:26:37

Explain some advantages and disadvantages of programming using Perl script language?

Advantages – Perl is a high-level programming language that is simpler to understand due to its syntax. It is also easier to use due to its flexibility, and easy readability. In addition, the language also supports OOP. It also becomes easier to understand since it has the ability to combine many languages.

Disadvantages – This software is not portable and has some unreadable codes. It is slower compared to other programming language since it is an interpretative language. When you apply any code which is more than 200 lines, it starts to give in problem within the program. It also contains a CPAN module which makes it incompatible to run on the system in which CPAN is not installed.

Posted Date:- 2021-09-06 03:25:46

What is Closure in Perl and how it is helpful?

It is defined as the block of code in Perl which is used for capturing the lexical variable which can be accessed at a later section in a program.

Posted Date:- 2021-09-06 03:25:00

How Local Operator and My Operator are different from one another?

Both these are methods that are useful for assigning private values to a block. Local Operator only operates on the Global Operator and it keeps the value of private operator. They can be accessed at the end of the block. My Operator is considered for creating a new variable. The variables created by it are always considered private and remain present in the block they are assigned.

Posted Date:- 2021-09-06 03:24:30

Does Perl have Objects? What is the best thing about them you have come across?

Yes, Perl is equipped with some very useful Objects. The best part is programmers are not forced to use them while performing their tasks. The users can easily skip them in case they don’t felt their need while writing the codes. Certain Object-Oriented modules are present in Perl and the users are free to consider them without actually understanding the objects. However, it is recommended to the programmers to go with the Objects in case the program is too complex.

Posted Date:- 2021-09-06 03:24:01

Can the Compiled Form is stored as a file in Perl?

No, it cannot be stored as a File

Posted Date:- 2021-09-06 03:23:40

What is the significance of Chop functions in Perl and how the users can keep up the pace with them?

Sometimes there is a need for the users to avoid some random characters from the expression. The same is done in Perl through the Chop Functions.

Posted Date:- 2021-09-06 03:23:21

R4R Team
R4R provides Perl Freshers questions and answers (Perl Interview Questions and Answers) .The questions on website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Perl interview questions part 2,Perl Freshers & Experienced Interview Questions and Answers,Perl Objetive choice questions and answers,Perl Multiple choice questions and answers,Perl objective, Perl questions , Perl answers,Perl MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Perl fresher interview questions ,Perl Experienced interview questions,Perl fresher interview questions and answers ,Perl Experienced interview questions and answers,tricky Perl queries for interview pdf,complex Perl for practice with answers,Perl for practice with answers You can search job and get offer latters by studing .learn in easy ways .