Perl Programming Perl Lists: Utilizing List::Util |
In our previous article we discussed, in large part, the split() function and its many uses. As those of you who read that article will recall, the split() function's main purpose is to take a string, break it apart, and return a list full of strings. There were many ways to do this and I think we covered the lion's share of them. Finally, we also went over how to assign a list to another list. And another list. And so forth. Before we begin talking about the first of our new subroutines, the first{BLOCK}List, let's look at a table describing what each of the seven do:
Before you begin tackling these examples, take note: you must add the following line to your code when using these subroutines. You add it near the top and you have to include any subroutine you plan on using throughout your program: Use List::Util qw(first max maxstr); If you were going to also use shuffle, you would write: Use List::Util qw(first max maxstr shuffle); and so forth. This tells the interpreter that you are going to use: first, max, maxstr, and shuffle in your program.
blog comments powered by Disqus |