If you take your time to skim through the Table of Contents of this eBook, you’ll see what you should expect to find here. For every data structure I give you a lot of examples about how to generate, access, print, append, insert, remove, replace, sort, copy, search or filter its elements.
In the same time you'll find a lot of example about how to use some important built-in functions with these structures. There are shown alternatives to iterate through these structure by using while, for, foreach, map or grep. You’ll find here a lot of commented examples to help you find a quick solution to your problem.
The examples included in this eBook are not only about complex data structures, but also show you how to use these structures together with operators, functions, subroutines, special variables, statements, regular expressions or with special notations as @$_, %{}, ||, &&, =>, @{}, [], {}, $_, $".
Complete solutions are provided for almost all the examples. Each example can be tested, modified and run individually. Every example shows you a way to resolve a specific problem, allowing you to find out a quick answer to your problem or question.
Of course you can continue searching through the forums to find the answer of your question but in this case you need to choose, test and interpret yourself the information provided there.
| 1. | Copyright |
| 2. | Introduction |
| 2.1. | How to run the examples included in this eBook |
| 2.1.1. | How to run the script in Windows |
| 2.1.2. | How to run the script in Linux |
| | |
| 3. | Perl Complex Data Structures |
| | |
| 3.1. | Array of Arrays (@AoA) |
| 3.1.1. | How to generate an array of arrays: |
| 3.1.1.1. | - using while |
| 3.1.1.2. | - using map |
| 3.1.1.3. | - from a csv file |
| 3.1.1.4. | - from a matrix contained in a text file |
| 3.1.2. | How to traverse and print an array of arrays: |
| 3.1.2.1. | - using for |
| 3.1.2.2. | - using foreach |
| 3.1.2.3. | - using grep |
| 3.1.2.4. | - using map |
| 3.1.2.5. | - using while |
| 3.1.3. | How to acces/modify the inner arrays elements |
| 3.1.4. | How to find the length of an array of arrays |
| 3.1.5. | How to find a specific string/substring in all inner arrays |
| 3.1.6. | How to join into a string the elements of a particular inner array |
| 3.1.7. | How to join into a string the elements of a matrix column |
| 3.1.8. | Turn each inner array into a string and get an array with all these strings |
| 3.1.9. | How to sort an array of arrays |
| 3.1.10. | How to sort a matrix by multiple columns |
| 3.1.11. | How to remove the first column from a matrix |
| 3.1.12. | How to remove the last column from a matrix |
| 3.1.13. | How to remove the first row from a matrix |
| 3.1.14. | How to remove the last raw from a matrix |
| 3.1.15. | How to clear an array of arrays |
| 3.1.16. | How to insert a column at the beginning of a matrix |
| 3.1.17. | How to insert a row at the beginning of a matrix |
| 3.1.18. | How to append a column to a matrix |
| 3.1.19. | How to append a row to a matrix |
| 3.1.20. | How to read a text file and push into columns |
| 3.1.21. | How to replace/remove in a matrix a contiguous slice of columns |
| 3.1.22. | How to get slices from an array of arrays |
| 3.1.23. | How to copy an array of arrays – shallow vs deep |
| 3.1.24. | How to pass an array of arrays reference to a subroutine |
| 3.1.25. | How to deal with autovivification in an array of arrays |
| | |
| 3.2. | Array of Hashes (@AoH) |
| 3.2.1. | How to generate an array of hashes |
| 3.2.2. | How to traverse and print an array of hashes: |
| 3.2.2.1. | - using for |
| 3.2.2.2. | - using foreach |
| 3.2.2.3. | - using grep |
| 3.2.2.4. | - using map |
| 3.2.2.5. | - using while |
| 3.2.3. | How to acces/modify the inner hashes elements |
| 3.2.4. | How to get an inner hash when a certain condition is met |
| 3.2.5. | How to extract the keys from an array of hashes |
| 3.2.6. | How to sort an array of hashes |
| 3.2.7. | How to remove the first element of an array of hashes |
| 3.2.8. | How to remove the last element of an array of hashes |
| 3.2.9. | How to delete a particular inner hash entry |
| 3.2.10. | How to clear the array of hashes |
| 3.2.11. | How to insert an element at the first position of an array of hashes |
| 3.2.12. | How to append an element to an array of hashes |
| 3.2.13. | Replace or remove a contiguous range of elements in an array of hashes |
| 3.2.14. | How to copy an array of hashes – shallow vs deep |
| 3.2.15. | How to pass an array of hashes reference to a subroutine |
| 3.2.16. | How to deal with autovivification in an array of hashes |
| | |
| 3.3. | Hash of Arrays (%HoA) |
| 3.3.1. | How to generate a hash of arrays |
| 3.3.2. | How to traverse and print a hash of arrays: |
| 3.3.2.1. | - using for |
| 3.3.2.2. | - using foreach |
| 3.3.2.3. | - using grep |
| 3.3.2.4. | - using map |
| 3.3.2.5. | - using while |
| 3.3.3. | How to acces/modify the inner arrays elements |
| 3.3.4. | Get the hash keys whose corresponding inner arrays match a certain criteria |
| 3.3.5. | How to sort a hash of arrays |
| 3.3.6. | How to remove the first element of each inner array |
| 3.3.7. | How to remove the last element of each inner array |
| 3.3.8. | How to delete a particular hash entry |
| 3.3.9. | How to clear a hash of arrays |
| 3.3.10. | How to insert new elements in front of a particular inner array |
| 3.3.11. | How to append new elements to a particular inner array |
| 3.3.12. | How to concatenate two matrices |
| 3.3.13. | How to copy a hash of arrays – shallow vs deep |
| 3.3.14. | How to pass a hash of arrays reference to a subroutine |
| 3.3.15. | How to deal with autovivification in a hash of arrays |
| | |
| 3.4. | Hash of Hashes (%HoH) |
| 3.4.1. | How to generate a hash of hashes |
| 3.4.2. | How to traverse and print a hash of hashes: |
| 3.4.2.1. | - using for |
| 3.4.2.2. | - using foreach |
| 3.4.2.3. | - using grep |
| 3.4.2.4. | - using map |
| 3.4.2.5. | - using while |
| 3.4.3. | How to access/modify an inner hash element |
| 3.4.4. | How to add another anonymous hash to a hash of hashes |
| 3.4.5. | How to represent a matrix as a hash of hashes |
| 3.4.6. | How to find the length of a hash of hashes |
| 3.4.7. | How to count the occurrences of a particular value in all inner hashes |
| 3.4.8. | Get and sort the values associated with a specific key in the inner hashes |
| 3.4.9. | How to sort a hash of hashes |
| 3.4.10. | How to delete an entry from an inner hash |
| 3.4.11. | How to delete a specific entry of a hash of hashes |
| 3.4.12. | How to clear a hash of hashes |
| 3.4.13. | How to copy a hash of hashes – shallow vs deep |
| 3.4.14. | How to pass a hash of hashes reference to a subroutine |
| 3.4.15. | How to deal with autovivification in a hash of hashes |
| | |
| 3.5. | More elaborate records |
| 3.5.1. | How to store multiple values to a single hash key |
| 3.5.2. | How to print a %HoHoH (a hash of hashes of hashes) |
| 3.5.3. | How to access complex data structures using a recursive subroutine |
| 3.5.4. | How to copy complex data structures – shallow vs deep |
| 3.5.5. | How to deal with autovivification in complex data structures |
| 3.5.6. | Hash of Functions |
If you consider that this book is valuable or you have some suggestions to improve its content, please send me some feedback through my contact page.