xie ningde wrote:
I'm a new perl user. I was trying to print an array by using print @array
and print "@array". Is it supposed to output the same thing? I got the
different output. EX: @array=qw/v1 v2 v3/, the output for print @array will
be v1v2v3 while it will be v1 v2 v3 in the other case. The difference is one
is seperated by whitespace while the other is not. Could anyone explain why
this happen? Thanks alot.

print @array;

Is equivalent to:

printf '%s%s', join( $,, @array ), $\;

And:

print "@array";

Is equivalent to:

printf '%s%s', join( $,, join( $", @array ) ), $\;


$ perl -e'
my @array = qw/v1 v2 v3/;
$, = "<  >";
$" = ";-:";
$\ = "* \n";

print @array, "END";
print "@array", "END";
'
v1<  >v2<  >v3<  >END*
v1;-:v2;-:v3<  >END*





John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to