Passing Values into Subroutines
When you've got local variables to store values specific to a subroutine, and return values to send data out from the subroutine, the only part of the subroutine left is getting information into it. For that you use arguments, just as you do for the built-in Perl functions.
Passing Arguments
Let's start with how arguments get passed into subroutines. Perl has an extremely loose notion of subroutine arguments. Whereas in other languages you have to be very specific when you write your subroutines to make sure you indicate how many and what type of arguments your subroutine will take, Perl doesn't care. When you call a subroutine in Perl, any and all arguments you give it are combined or expanded into a single list ...
Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.