$name = "Larry Wall"; print "Hello there, $name, did you know that 3+4 is ", 3+4, "?\n";
Of course, that means printing an array and interpolating an array are different:
print @array; # print a list of items print "@array"; # print a string (containing an interpolated array)
@array into the empty string—that is, it prints the contents of
@array, separated by spaces. If
qw/ fred barney betty /, the first one will print
fredbarneybetty, and the second will print
fred barney betty separated by spaces.
But before you decide to use the second form all the time, imagine that
@array is a list of unchomped lines of input. That is, imagine that each of its strings has a trailing newline character. Now, the first
betty on three separate lines. But the second one prints this:
fred barney betty
Do you see where the spaces come from? Perl is interpolating an array, so it puts spaces between the elements. We get the first element of the array ...