Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 6. References > Item 64. Use map and grep to manipulate complex data st...

Item 64. Use map and grep to manipulate complex data structures

Sometimes it’s useful to take a “slice” of a multidimensional array or hash, or to select slices that have certain characteristics. Conversely, you may need to assemble a collection of lists into a two-dimensional array, or perhaps assemble a collection of two-dimensional arrays into a three-dimensional array. Perl’s map and grep operators are perfect choices for chores like these.

Slicing with map

Begin with a program that reads a file of three-dimensional coordinates into memory. The example file has these data:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint