LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: comdog@cvs.perl.org Date: Sat Aug 16 00:36:49 2008 Subject: [svn:perlfaq] r11654 - perlfaq/trunk
Author: comdog Date: Fri Aug 15 23:36:48 2008 New Revision: 11654 Modified: perlfaq/trunk/perlfaq5.pod Log: * perlfaq5: Why do I get weird spaces when I print an array of lines? + fixed typos and grammar Modified: perlfaq/trunk/perlfaq5.pod ============================================================================== --- perlfaq/trunk/perlfaq5.pod (original) +++ perlfaq/trunk/perlfaq5.pod Fri Aug 15 23:36:48 2008 @@ -1331,19 +1331,19 @@ print "animals are: @animals\n"; It's the double quotes, not the C<print>, doing this. Whenever you -interpolate an array in a double quote contexts, Perl joins the +interpolate an array in a double quote context, Perl joins the elements with spaces (or whatever is in C<$">, which is a space by default): animals are: camel llama alpaca vicuna -This is different than print the array without the interpolation: +This is different than printing the array without the interpolation: my @animals = qw(camel llama alpaca vicuna); print "animals are: ", @animals, "\n"; Now the output doesn't have the spaces between the elements because -the elements of C<@animals> simply becoming part of the list to +the elements of C<@animals> simply become part of the list to C<print>: animals are: camelllamaalpacavicuna @@ -1357,8 +1357,8 @@ this is the third line That extra space comes from the interpolation of the array. If you -don't want to put anything between your array elements, don't use it -in double quotes. You can send +don't want to put anything between your array elements, don't use the +array in double quotes. You can send it to print without them: print @lines;
| Navigate in group perl.cvs.perlfaq at sever nntp.perl.org | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |