- Assignment Operators
- Increment and Decrement Operators
- String Concatenation and Repetition
- Operator Precedence and Associativity
- Using Patterns to Match Digits
- An Example: Simple Statistics
- Input and Output
- Another Example: Stocks
- A Note About Using Functions
- Going Deeper
- Summary
- Q&A
- Workshop
- Answers
Summary
Today was Part 2 of everything you ever wanted to know, and probably a whole lot you didn't, about scalar data. Today you got to look at more tables of operators, in particular operators for assigning things to variables, or changing the values of variables, and for concatenating and repeating strings. You also learned about operator precedence, which determines which operators get to go first when you have an expression with lots of them in it.
Along the way you also learned about pattern matching with digits and some about if and while (although you'll learn a whole lot more about them on Day 6).We finished today's lesson talking about input and output, and in particular using <STDIN> to get data into a Perl script and the various print functions to print it out again. You also learned a bit about calling functions with and without parentheses around their arguments.
The built-in functions you learned about today include (see the perlfunc man page for more details about these functions):
print takes a list of comma-separated values and strings to print and outputs those values to the standard output (STDOUT).
printf takes a formatting string and any number of values, and prints those values according to the codes in the formatting string.
sprintf does the same thing as printf, except it returns the formatted string without printing anything.
chomp with a string argument removes any trailing newlines from that string and returns the number of characters it deleted.
chop is the older version of chomp; it removes the last character from the string and returns the character it removed.