Perl Programming - Working with Subroutines outro
Get the entire Perl Programming course for 20% off: http://stoneriverelearning.com/courses/perl-programming-for-beginners-online-course?product_id=38639&coupon_code=YOUTUBE20
Congratulations, guys! You guys made it through our section 5, Working with Subroutines. Again, like I’ve promised you, this is the conclusion and let’s dive right into it.
What did you guys learn in this section? Well, we went over the subroutine definitions and we’ve learned how to develop the skills to create and declare our own personal subroutines and our definitions. The definitions is just pretty much what do we want our subroutines to do, what operations do we want it to perform and what serves the purpose of a subroutine? We want it to do something, perform an action.
Secondly, we’ve learned how to call and use these subroutines, not only yet we can of course create these subroutines but we want to be able to use them. That’s the whole point of creating the subroutines. Now we know how to call the subroutines that we set up with our subroutine definitions.
Thirdly, working with subroutine return values. Of course, this is extremely important in some cases. If you want to perform an action and you want it to return some kind of information so you can work with that information in a different part of your Perl program. Again, normally all subroutines in Perl built in the subroutines return some kind of value, but with ours, we don’t have to. But in this case, we will want to return some kind of value based on an expression.
Subroutine arguments. Not only that we can hardcode information in our subroutines. We can actually get information from our users now using subroutine arguments which is independent data from the user.
Using variable-length parameter lists. This gives us the ultimate power to get an unlimited number of items and values from our users. But if we only want specific parts of information and limit the user, we can by using variable length parameter list.
Using the return operator. This return operator will allow us to return some calculated information to give our program a Perl program. Also the return operator is used to let the subroutine know that it’s done executing code and it wants to exit out of the subroutine and continue and resume line by line, execute our Perl instructions that’s after our subroutine.
Private variables in subroutines. Again, private variables are nothing more but scalar variables that only private and only seen within the subroutine. No other part of your Perl program can see these private variables when you set them up as private. Only within your subroutine it’s pretty much seen within your subroutine.