in reply to Re: array join missing zero and space
in thread array join missing zero and space
use strict; use warnings; my @numbers = (4,7,11,14); my $start='0 '; #print join ("$start" , @numbers),"\n"; print join ' ', map { 0, $_ } @numbers;
The code above gives this:
Not enough arguments for map at 910662.pl line 9, near "} @numbers" syntax error at 910662.pl line 9, near "} @numbers" Execution of 910662.pl aborted due to compilation errors.
I tried this:
print join ' ', map { ' 0 ' . $_ } @numbers;And get this:
0 4 0 7 0 11 0 14Not sure where the extra spaces after 4,7 and 11 come from.
Update: duh, the join has a space.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: array join missing zero and space
by mykl (Monk) on Jun 21, 2011 at 13:51 UTC | |
|
Re^3: array join missing zero and space
by ikegami (Patriarch) on Jun 21, 2011 at 16:32 UTC |