Interview :: Perl
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.
How to sort arrays in Perl?
The Perl sort array function sorts all the elements of an array according to the ASCII standard.
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.
What are the hashes?
A hash is a collection of key-value pairs
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.
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.
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.
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.
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.