Manipulating Function Arguments
Explore how Perl flattens function arguments and how to manipulate them effectively. Understand dealing with lists, hashes, and scalars in parameters, using experimental signatures, and the implications of aliasing @_ for safer, clearer, and maintainable code.
We'll cover the following...
We'll cover the following...
Flattening
List flattening into @_ happens on the caller side of a function call. Passing
a hash as an argument produces a list of key/value pairs:
When Perl flattens %pet_names_and_types into a list, the order of the key/value pairs from the hash will vary, but the list will always contain a key, immediately followed by its value. Hash assignment inside show_pets() works the same way as ...