The syntax <<something
starts here — a document borrowed from UNIX shells through Perl is basically a multi-line string literal that starts in the line after <<
and ends when the line starts with something
.
So structurally, the program simply does this:
puts str*2,2
... that is, print two copies of str
, and then number 2.
But instead of the str
variable, it includes a literal string through the document here, the end of which is also the number 2:
puts <<2*2,2 puts <<2*2,2 2
Thus, he prints two copies of the line puts <<2*2,2
, followed by 2. (And since the method used to print them puts
, each of these things automatically adds a new line.)
source share