Summary

Learning the Perl language involves learning much more than just the syntax of the core language; the built-in functions provide a lot of the cooler functionality and the power of Perl scripts. Although many of the functions accomplish things in the language that can be better done some other way, others are useful to at least have around for specific cases. The functions you've learned about in this lesson are like that; most everything you've learned here can be done in some other way, although sometimes that other way might be longer, less efficient, or harder to figure out.

Today, then, you learned about the various functions you can use to modify lists and strings, and the ways to use these functions to accomplish simple tasks. You also learned about array and hash slices, which, although they aren't actually functions, give you a method for extracting elements out of a list or hash.

The functions you've learned about today include

  • sort, for sorting lists

  • grep, for extracting list elements that match a criteria such as a pattern

  • push and pop, for adding or removing list elements to the end of a list

  • shift and unshift, for adding and removing list elements to the beginning of a list

  • splice, for adding, removing or replacing elements from anywhere in a list

  • reverse, to reverse the order of elements in the list, or, in scalar context, for reversing the order of the characters in a string

  • join, the reverse of split, for combining list elements into a string with one or more characters between them

  • map, for performing some operation on each element of a list and building a new list of the results

  • index and rindex, for finding the position of a given string in another string

  • substr, for removing, adding, or replacing one string with another

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.247.166