Printing Output : Print « Language Basics « Perl






Printing Output

  

#The print and printf functions are built-in functions used to display output.

#The print function arguments consist of a comma-separated list of strings and/or numbers.

#The printf function is used for formatting output.

#Parentheses are not required around the argument list.

#print value, value, value;
#printf ( string format [, mixed args [, mixed ...]] );


print "Hello, world\n";
print "Hello,", " world\n";
print ("this is a test!\n");  
print "The the date and time are: ", localtime, "\n";
printf "Hello, world\n";
printf("Meet %s%:Age 5d%:Salary \$10.2f\n", "John", 40, 55000);

   
    
  








Related examples in the same category

1.Prints a welcome statement with escape character
2.Prints a welcome statement with several escape characters
3.You can pass a list of items to print, where you separate the list items with commas:
4.The print command prints out the text you provide it
5.Output two values in one print statement
6.print "Hello!\n";
7.Using comma in a print statement
8.Mix the string the integer calculation in a print statement
9.Output the result of multiply with string
10.Output the result of division with string
11.Print only care about the first parenthesis
12.Put all into a parenthesis for print statement
13.Get the Power
14.Using Perl Built-in Functions
15.print function prints a string or a list of comma-separated words to the Perl filehandle STDOUT.
16.If the strings are not quoted, the filehandle STDOUT must be specified, or
17.The filehandle STDOUT must be specified if strings are not quoted.
18.Printing Numeric Literals
19.Printing String Literals
20.surrounding FINIS with single quotes
21.x 4 says that the text within the here document will be printed four times.
22.If terminator is in backquotes, will execute OS commands
23.The HTML tags are embedded in the here document to avoid using multiple print statements
24.Format text output with HTML tags
25.print 16 % 3;
26.print 2048 >> 3;
27.print 24 & 15;
28.print sqrt 4;
29.print -e STDIN; #Does STDIN exist?
30.print -t STDIN; #Is it tied to a terminal?
31.print -z STDIN; #Does it have zero size?
32.print $_ >= 0 ? $_ : -$_
33.print $_ < 10 ? $_ : "${\((a .. f)[$_ - 10])}\n";
34.print 1, 2, 3, 4, sort 9, 8, 7, 6, 5;
35.Print out here document
36.Syntax for the print Function
37.printf function prints a formatted string.
38.printf Flag Modifiers
39.Using the print Function