O'Reilly logo

Learning Perl, Second Edition by Randal L. Schwartz, Tom Christiansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.8. Output with print

So, we get things in with <STDIN>. How do we get things out? With the print function. This function takes the values within its parentheses and puts them out without any embellishment onto standard output. Once again, unless you've done something odd, this will be your terminal. For example:

print("hello world\n"); # say hello world, followed by newline
print "hello world\n";  # same thing

Note that the second example shows the form of print without parentheses. Whether or not to use the parentheses is mostly a matter of style and typing agility, although there are a few cases where you'll need the parentheses to remove ambiguity.

We'll see that you can actually give print a list of values, in Section 6.3.1, but we haven't talked about lists yet, so we'll put that off for later.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required