Summary

Numbers and strings everywhere! Today you learned quite a lot about scalar data. Perl uses the term scalar data to refer to single things, and most particularly numbers and strings. Scalar variables, which start with $, hold scalar data.

With scalar data in hand, you can create Perl statements, perform arithmetic, compare two values, assign values to variables, change the values of variables, and convert between numbers and strings.

Today you also learned a little about pattern matching, including the pattern matching operators =~ and !~, and the pattern operator m//.

The built-in functions you learned about today include these (we'll go into more detail about some of these tomorrow; 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.

  • int takes a number and returns the integer part of that number (truncating any decimal part).

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

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