Home / Interview / Perl :: General Questions

Interview :: Perl

21)

What are arrays in Perl?

An array contains an ordered list of scalar values. It is preceded with (@) sign. To access a single element in a Perl array ($) sign is used.

22)

How to find the length of an array in Perl?

Size of an array is determined with scalar context on the array. Array length will always be one greater than its largest index.

Perl size = $#arrayName +

Where $#arrayName is the maximum index of the array.

23)

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

24)

What is Perl push array function?

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

25)

What is Perl pop array function?

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

26)

What is Perl shift array function?

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

27)

What is Perl unshift array function?

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

28)

How to replace Perl array elements?

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

29)

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.

30)

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.