Home
21.
How are multidimensional arrays possible using Perl?

References in Perl point to scalars only. References to arrays point to the beginning of the array.
Arrays can contain references to other arrays, hashes, and so on. The way to create multidimensional arrays in Perl is by using references to references.

22.
How do I know what type of address a pointer is pointing to?

The address printed out with the print statement on a reference has a qualifier word in front of it.
For example, a reference to a hash has the word HASH followed by an address value, an array has the word ARRAY, and so on

23.
Why is *moomore efficient to use than $_main{'moo'}? Is there a difference in usage?

Both *moo and $_main{'moo'}mean the same variable (as long as you aren't using a package).
*moo is more efficient because the reference is looked up once at compile time, whereas $_main{'moo'}is evaluated at runtime and evaluated each time it is run.

24.
Why do some system variables use special characters rather than letters in their names?

To distinguish them from variables that you define and to ensure that the reset function cannot affect them.

25.
Why do some functions use $_as the default, whereas others do not?

The functions that use $_as the default are those that are likely to appear in Perl programs specified on the command line using the -e option

26.
If you don’t include an explicit call to return in your script, what value does a subroutine return?

Without an explicit return, subroutines return the last value that was evaluated in the block.

27.
Is the argument that gets returned from the subroutine with return a scalar or a list value?

Trick question! Return can be used to return either a scalar or a list, depending on what you want to return.

28.
What happens to a hash you pass into a subroutine?

When you pass any list into a subroutine, it is flattened into a single list of scalar values. In the case of hashes, this means unwinding the hash into its component keys and values (the same way a hash is handled in any general list context).

29.
What is @_ used for? Where is it available?

@_ refers to the argument list of the current subroutine. It’s most commonly used inside a subroutine definition, although you can also define is as a global variable

30.
How do you name parameters in a Perl subroutine?

Perl does not have formal named parameters. You can extract elements from the argument list @_ and assign them to local variables in the body of your subroutine (although once assigned to local values, they cease to be references to the same values outside that subroutine).