From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Statements and expressions - Perl Tutorial
From the course: Perl 5 Essential Training
Statements and expressions
- [Voiceover] In Perl, the concepts of statements and expressions overlap a bit. Let's take a look at what this means. Here's a working copy of countlines3.pl from Chapter 3 of the exercise files. In general, a statement tells the computer what action to take, and an expression represents a value. A given line of code may be a statement, an expression, or both. For example, line 13 contains an expression. The value is the name of the file, either from the command line via the shift operator or from the literal string linesfile.txt. An expression is anything that returns a value, so in this case, the literal string returns a value, the shift returns a value, the result of shift or the literal string returns a value, and the assignment returns a value. The assignment is also a statement. Line 15 is a statement. It calls built in function, say, to display a string on the console. In Perl, a semicolon is used to separate statements. In other words, the semicolon at the end of line 15 is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.