O'Reilly logo

Sams Teach Yourself Perl in 21 Days, Second Edition by Rafe Colburn, Laura Lemay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required