Using References with Subroutine Arguments and Return Values

So far, you've got a basic idea of how references work. There's still lots more detail to explain about creating and using references, but let's stop for a moment and do something practical. On Day 11, “Creating and Using Subroutines,” when we talked about sub- routines, I mentioned that lists and subroutines tend to be somewhat awkward without references. Let's revisit that topic and explore how references can make subroutine list arguments and return values much easier to manage.

Subroutine Arguments

As you already know, Perl has a very basic capability to pass arguments into and out of subroutines. All list arguments into a subroutine are flattened into a single list and stored in ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.