Perl Programming Perl Lists: A Final Look at List::Util |
In our previous article we discussed the first{block}List subroutine, which returned the first value in a list. It also could be used to return the first value in a list that met a specific criteria, such as the first value greater than "x" or the first value greater "x" but less than "y," and so forth. We also covered max(List), which finds and returns the maximum numeric value in a list, and maxstr(List), which find the maximum string value in a list. We learned that, where Perl is concerned, "z" is greater in value than "Z," "A," and "a." Before we begin covering the last of our subroutines, let's take a final look at the List::Util table:
Also remember that before you can use any of the List::Util subs, you must include them near the top of your code, like so: use List::Util qw(maxstr); And you must make sure to include whatever subroutines you are going to use in your program in the parameters of qw(). For example: use List::Util qw(minstr sum min shuffle); would allow you to use the minstr, sum, min, and shuffle subroutines.
blog comments powered by Disqus |