Take the 2-minute tour ×

When I learning to print array variables, I found the white space inserted when double quoter used. Snippet code as below. Could you please tell me why?

#!/usr/bin/perl -w
use strict;
use warnings;

my @str_array = ("Perl","array","tutorial");
my @int_array = (5,7,9,10);

print @str_array;
print "\n";
# added the double quotes
print "@str_array";
print "\n";
print @int_array;
print "\n";
# added the double quotes
print "@int_array";


Perl array tutorial
5 7 9 10
share|improve this question
add comment

2 Answers

When a variable is used inside a string, string interpolation is used. String interpolation means, among other things, the variable is formatted to become a string. When an array variable is formatted to become a string it is given spaces between the elements. These spaces are actually determined by the variable $". The default value for this variable is a space. For more information see the perl documentation for special variables.

share|improve this answer
add comment

Your Answer


