60+ Online Perl Interview Questions

Online Perl Interview Questions

Perl Interview Questions

1. What is Perl?

Perl represents Practical Extraction and Reporting Language. It is an abnormal state programming language composed by Larry Wall, extraordinarily intended for handling content. It bolsters object-arranged programming, and its linguistic structure is very like C language. It is considerably more adaptable to utilize. Because of its solid content handling capacities, it has turned out to be a standout amongst the most prevalent dialects for composing CGI contents.

2. Is Perl Compiler or Interpreter?

Perl is said to be both compiler and mediator. It peruses the source code, changes over the program into bytecode before execution and after that runs it. Thus, Perl is some of the time called a mediator/compiler.

3. Which operator in Perl is used for the concatenation of two strings?

The operator used for the concatenation of strings is (.) operator.

4. What is CPAN in Perl?

CPAN stands for Comprehensive Perl Archive Network. It is a repository which contains thousands of Perl modules.

5. What are the features of Perl language?

The component of Perl: 
  • It has an extremely straightforward Object-arranged programming language structure. 
  • It is effectively extendible as it underpins 25,000 open source modules. 
  • It bolsters Unicode. 
  • Incorporates amazing assets to process content to make it good with markup dialects like HTML, XML. 
  • It bolsters outsider database including Oracle, MySQL, and numerous others. 
  • It is embeddable in different frameworks, for example, web servers and database servers. 
  • It is open source programming authorized under GNU. 
  • Numerous structures are written in Perl. 
  • It can deal with scrambled web information including internet business exchanges. 
  • It is a cross-stage language. 
  • It offers a normal articulation motor which can change any content.

6. What are the advantages and disadvantages of Perl language?

Perl focal points: 
  • Its language structure is straightforward, which makes it straightforward. 
  • It underpins OOP ideas. 
  • Perl programs run effectively on the framework. 
  • It is increasingly adaptable to utilize. 
  • It bolsters all stages and is substantially more versatile. 
  • It has a rich arrangement of Perl modules and free programming. 
  • It is considerably more proficient to chip away at content and string control as it is a scripting language. 
  • Perl joins highlights of numerous different dialects which make it straightforward. 
  • Perl burdens 
  • A Perl program containing CPAN modules won't keep running on another framework which doesn't have CPAN modules introduced. 
  • It is an interpretative language, so it is slower in correlation with different dialects. 
  • It has messy and incomprehensible codes. 
  • It begins making issues when the code is bigger than 200 lines. 
  • It isn't compact.

7. Define print() function in Perl?

The Perl print() function prints anything it gets as its argument.

8. Define say() function in Perl?

The Perl state() work isn't upheld by more seasoned Perl adaptations. It resembles Perl print() work with just a single distinction that it consequently includes another line toward the end.
Define dynamic scoping.
The assignment of temporary values to the global variables is called as dynamic scoping.
Explain lexical variables.
The variables which are created by the use of 'my' operator and private in nature are called as lexical variables.

9. When does circular reference occur?

When the two references also contain references to each other, then the case of circular reference occurs.

10. What happens in dereferencing?

Value to the location from the reference point is returned.

11. What does read () command do?

The read() command is used to read the block of information from the buffered file handle.
What is the use of 'ne' operator?
The operator compares the value of the left string to the right one and returns true if they are not equal.

12. What does the q{ } operator do?

The operator encloses a string in the single quotes.

13. What does the qq{ } operator do?

The operator encloses a string in the double quotes.

14. What does the qx{ } operator do?

The operator encloses a string in the inverted quotes.

15. How many data types are there in Perl?

Perl has three data types:
  • Scalars
  • Arrays
  • Hashes

16. What are Perl variables?

A variable is a place to store values reserving some memory space. Perl treats the same variables differently based on context.
There are three types of Perl variables:
  • Scalars
  • Arrays
  • Hashes

17. What are scalars?

A scalar contains a solitary unit of information. They are gone before with a ($) sign. A scalar contains a number, character, reference or a string. A reference is the location of the variable.

18. What are arrays in Perl?

An exhibit contains an arranged rundown of scalar qualities. It is gone before with (@) sign. To get to a solitary component in a Perl exhibit ($) sign is utilized.

19. How to find the length of an array in Perl?

Size of an exhibit is resolved with scalar setting on the cluster. Exhibit length will dependably be one more prominent than its biggest file.
Perl measure = $#arrayName +
Where $#arrayName is the most extreme file of the exhibit.

20. What are Perl array functions?

Perl array functions are used to add or remove some elements in an array.
There are four types Perl array functions:
  • Push
  • Pop
  • Shift
  • Unshift

21. What is Perl push array function?

The Perl push array function appends a new element at the end of an array.

22. What is Perl pop array function?

The Perl pop array function removes the last element of an array.

23. What is Perl shift array function?

The Perl shift array function removes the leftmost element from the array shortening array by 1.

24. What is Perl unshift array function?

The Perl shift array function adds a new element at the start of an array.

25. How to replace Perl array elements?

The Perl splice array function removes elements and replaces them with the specified list of elements.

26. How to convert strings into an array in Perl?

The Perl split array function splits a string into an array of strings. Thus converting strings into an array.

27. How to convert arrays into a string in Perl?

The Perl join array function combines more than one array into a single string. Thus converting arrays into a string.

28. How to merge two arrays in Perl?

The Perl merged array function merges two arrays into a single array by removing all the commas in between them.

29. How to sort arrays in Perl?

The Perl sort array function sorts all the elements of an array according to the ASCII standard.

30. What are the hashes?

A Perl hash is a gathering of unordered key-esteem sets. The keys are one of a kind strings and qualities are scalar qualities. It is gone before with (%) sign. They can be gotten to utilizing their key qualities.

31. How to know whether a key exists or not in Perl?

Utilizing Perl exists work, you can check whether a key exists or not in a hash. It returns genuine if the key exists.

32. How to add elements in a hash in Perl?

To add a new key-value pair in the hash, declare them as a single variable in the hash variable.

33. What does delete function do in Perl?

To remove a hash element, use delete function. It removes both key and value element from the hash.
What does undef function in Perl?
The undef function removes the value from the hash, but its key remains there.

34. What is the difference between Perl array and Perl hash?

Perl cluster: They are an arranged rundown of components, situated by file number. It is meant with @ sign.
Perl hash: They are an unordered rundown of components, situated by their key qualities. It is signified with a % sign.

35. What is the difference between Perl list and Perl array?

Perl list is a strategy to sort out information in the Perl source code. It is a fixed accumulation of scalars. They are constantly one dimensional.
Perl exhibit is a technique to store information as factors. They are multi-dimensional.

36. What is the difference between use and require in Perl?

Use: It is utilized just for the Perl modules. The included modules are checked at the season of accumulation. It needn't bother with the record augmentation.
Require: It is utilized for both Perl modules and libraries. The included articles are confirmed at runtime. It needs the record expansion.

37. How many loop control keywords are there in Perl?

There are three types of loop control statement:
  • Next
  • Last
  • Redo

38. What does next statement do in Perl?

Perl next proclamation resembles proceed with articulation in C. It gives you a chance to proceed onward to the following component of your exhibit or hash avoiding all components in the middle.

39. What does last statement do in Perl?

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

40. What does redo statement do in Perl?

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

41. Why do we use "use strict" in Perl?

The "utilization strict" order in Perl calls strict pragma. This pragma gets a few bugs or mistakes in our content and stops the program execution.

42. What are Perl strings?

Strings are a fundamental piece of Perl. They are scalars, so they begin with $ sign. Strings can be put inside single or twofold statement.
Two sorts of string administrators are there: 
  • Link (.) 
  • Redundancy (x)

43. What is an interpolation in Perl?

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

44. What is the difference between single (') and double (") quote in a string in Perl?

In the single statement, the esteem is printed as it is given inside the string without addition.
In the twofold statement, the esteem is printed with interjection given inside the string.

45. Explain substr function in Perl?

The substr function is used to truncate the string. The string will be truncated to offset value we provide.

46. How to compare two strings in Perl?

To compare two strings in Perl eq is used instead of (==). It checks whether two strings are equal or not.

47. How to determine strings length in Perl?

String length can be determined with length() function.

48. What is qq (double q)operator in Perl?

The qq operator replaces double quote surrounding a string by its parentheses. You can use qq instead of ("").

49. What is q (single q) operator in Perl?

The q operator replaces single quote surrounding a string by its parentheses. You can use q instead of (').

50 What is STDIN in Perl?

The STDIN stands for standard input. Using this input, we can get input from the standard console. It can be abbreviated as <>.

51. What is goto statement in Perl?

The Perl goto statement is the jump statement. It transfers control by jumping to another label inside a loop.
There are three goto forms:
  • goto LABEL
  • goto EXPR
  • goto &NAME

52. How to do comment in Perl?

Like other languages, Perl also provides comment facility in its code. There are a single line and multi-line comment.
For single line comment: use # before the line you want to comment.
For multi-line comment: use =begin and =cut statement before and after the lines respectively you want to comment.

53. Explain regular expression in Perl?

A regular expression is a string of characters that defines a specific pattern.
There are three regular expression operators inside Perl:
Matching regular expression operator, m//
Substitute regular expression operator, s///
Transliterate regular expression operator, tr///

54. Explain subroutine in Perl?

Perl subroutine gives you a chance to reuse code in your program. They acknowledge contentions, play out their activity and return the qualities. A subroutine is announced with 'sub' watchword before its name. In Perl, capacity and subroutine are utilized conversely.

55. How to read a directory in Perl?

The readdir work is utilized to peruse an index in Perl. In scalar setting, it will restore every thing one by one. In rundown setting, it will restore all the substance of the registry in one articulation. So list setting utilizes more memory than scalar setting.

56. Explain socket programming in Perl?

The attachment is a technique which sets up a virtual association between various procedures over a system.
In attachment programming, customer and server-side content are made which impart through one another over TCP/IP convention.