If you print an array inside double quotes, each item of the array is separated by the value specified in Perl special variable $" which is the Output list separator. (interpolated lists)
By default the value of $" is space
So you can rewrite your code modifying the Output list separator
#Example 1
## check Array vis-a-vis List
@arr = qw <hello happy new year 2013>;
{
local $" = "";
print "my array is : @arr \n";
}
## lets print in a loop
my $i = 0;
while ($i <= $#arr)
{
print $arr[$i];
$i += 1;
}
print "\n";
or place the array outside double quotes,in such case interpolation will not happen.
#Example 2
## check Array vis-a-vis List
@arr = qw <hello happy new year 2013>;
print "my array is : ", @arr, "\n";
## lets print in a loop
my $i = 0;
while ($i <= $#arr)
{
print $arr[$i];
$i += 1;
}
print "\n";
best,
Shaji
-------------------------------------------------------------------------------
Your talent is God's gift to you. What you do with it is your gift back to God.
-------------------------------------------------------------------------------
________________________________
From: Neeraj <neeraj...@gmail.com>
To: begi...@perl.org
Sent: Wednesday, 2 January 2013 4:05 PM
Subject: Array vs List output
Thanks for your clarification.
I used to call it as Output List Separator, now I knew it is just List Separator.
best,
Shaji
-------------------------------------------------------------------------------
Your talent is God's gift to you. What you do with it is your gift back to God.
-------------------------------------------------------------------------------
________________________________
From: John W. Krahn <jwk...@shaw.ca>
To: Perl Beginners <begi...@perl.org>
Sent: Wednesday, 2 January 2013 6:11 PM
Subject: Re: Array vs List output
-- To unsubscribe, e-mail: beginners-...@perl.org
For additional commands, e-mail: beginne...@perl.org
http://learn.perl.org/