From the course: Perl 5 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

The print() and say() functions

The print() and say() functions - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

The print() and say() functions

- The print and say functions are used for displaying text on the console. They're also used for writing text to files and streams. Here's a working copy of hello.pl from chapter 13 of the Exercise Files. The only difference between print and say is that the say function adds a new line at the end of its output. So, if I come down here to our say function, and I just copy and paste this a few times, when I run it, you notice that the output of each say function is on its own line. So, it outputs the string that's the argument, or whatever's in the argument list. And then, when it's all done with that, it puts out a new line character, so that any output after that starts on the next line. And so, in this case, what output is after that is another say function and then another one. And they're all on the same line. If instead I were to make this the print function and use that three times, you notice that the output is all on one line, because the print function does not add that new…

Contents