In both cases you have an array and print does not insert any extra characters between the elements of an array. You can use join to do that however:
use strict; my @days; @days = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday); print ((join ' ', @days), "\n"); print join ' ', qw(Monday Tuesday Wednesday Thursday Friday), "\n";
Prints:
Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday
To see why I put the brackets in try these two lines:
print ((join ' ', @days), "x\n"); print join ' ', @days, "x\n"; #prints: Monday Tuesday Wednesday Thursday Friday Saturday Sundayx Monday Tuesday Wednesday Thursday Friday Saturday Sunday x
Note the space before the x in the second line because @days, "x\n" is a list that join acts on, rather than the paraneter for join followed by a parameter for print.
In reply to Re: Using qw
by GrandFather
in thread Using qw
by Tech77
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |