Chapter 3
Variables
WHAT YOU WILL LEARN IN THIS CHAPTER:
- Understanding programming in Perl
- General things to remember as you work with variables
- Understanding scalars
- Using data in arrays and hashes
- Working with array and hash slices
- Implementing scalar and list content
- Understanding the scope of variables
- Working with strict, warnings, and diagnostics
- Using Perl’s context feature
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapterare found at http://www.wrox.com/WileyCDA/WroxTitle/Beginning-Perl.productCd-1118013847,descCd-DOWNLOAD.html on the Download Code tab. The code for this chapter is divided into the following major examples:
- example_3_1_variable.pl
- example_3_2_diagnostics.pl
- exercise_3_2a_array.pl
- exercise_3_2b_array.pl
- exercise_3_3_fruit.pl
- listing_3_1_scope.pl
- listing_3_2_vars.pl
- listing_3_3_our.pl
- listing_3_4_diagnostics.pl
- listing_3_5_hello.pl
This chapter examines the three primary data types of Perl: scalars, arrays, and hashes. Unlike many other languages that focus on things such as strings, integers, floats, and so on, Perl’s types focus on how you organize your data, rather than what the data is. It’s an approach to data types that is unusual to those who think of “types” as restricting data to certain values, but in practice, it’s a robust, powerful approach that many other programming languages follow.
Don’t worry about the size of this chapter because you won’t need to memorize it. Most of this information will be reinforced ...
Get Beginning Perl now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.