Home / Interview / Perl :: General Questions

Interview :: Perl

31)

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.

32)

How to sort arrays in Perl?

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

33) What are the hashes?

A Perl hash is a group of unordered key-value pairs. The keys are unique strings and values are scalar values. It is preceded with (%) sign. They can be accessed using their key values.

click here.

34)

What are the hashes?

A hash is a collection of key-value pairs

35)

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

Using Perl exists function, you can check whether a key exists or not in a hash. It returns true if the key exists.

36)

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.

37)

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.

38)

What does undef function in Perl?

The undef function removes the value from the hash, but its key remains there.

39) What is the difference between Perl array and Perl hash?

Perl array: They are an ordered list of elements, positioned by index number. It is denoted with @ sign.

Perl hash: They are an unordered list of elements, positioned by their key values. It is denoted with a % sign.

40) What is the difference between Perl list and Perl array?

Perl list is a method to organize data in the Perl source code. It is a fixed collection of scalars. They are always one dimensional.

Perl array is a method to store data in the form of variables. They are multi-dimensional.