in reply to Re^2: Concatenate printing a string and array
in thread Concatenate printing a string and array
Try something like assigning $" the empty string instead of undef:>perl -wMstrict -le "my @ra = (1,2,3,4,5); { $\" = ''; print qq{@ra}; } "
You are correct about the use of undef but the local that CountZero used is necessary otherwise the change is global in scope.
$ perl -Mstrict -wle ' > my @arr = ( 1, 2, 3 ); > print qq{@arr}; > { $" = q{}; print qq{@arr} } > print qq{@arr};' 1 2 3 123 123 $
I usually limit the scope to the print itself by using a do BLOCK.
$ perl -Mstrict -wle ' my @arr = ( 1, 2, 3 ); > print do{ local $" = q{}; qq{@arr} };' 123 $
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Concatenate printing a string and array
by spickles (Scribe) on Jan 05, 2009 at 20:09 UTC | |
by johngg (Canon) on Jan 05, 2009 at 23:52 UTC | |
|
Re^4: Concatenate printing a string and array
by AnomalousMonk (Archbishop) on Jan 05, 2009 at 18:46 UTC | |
by johngg (Canon) on Jan 05, 2009 at 20:19 UTC | |
by AnomalousMonk (Archbishop) on Jan 07, 2009 at 04:23 UTC |