Logo

Programming-Idioms

History of Idiom 2 > diff from v20 to v21

Edit summary for version 21 by :
[Perl] Added version using "say"

Version 20

2016-01-05, 18:09:27

Version 21

2016-01-07, 19:47:56

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Code
print "Hello\n" for 1 .. 10;
Code
print "Hello\n" for 1 .. 10;

# Recent (5.10 and later) versions of perl also provide the
# say function, which automatically adds the newline
say "Hello" for 1 .. 10;
Comments bubble
Note the necessary newline (\n), not to print every time on the same line
Comments bubble
Note the necessary newline (\n), not to print every time on the same line