eventual wrote:
Hi, How do I change the default list seperator.
I tried the following but it wont work. Thanks

$testing = "anything in here";
@rubbish = $testing;

You are assigning one scalar value to the whole array so only $rubbish[0] will have any content.


$" = "in";

This is the correct way to change the value of the LIST SEPARATOR variable.


print "\@rubbish now have " . $#rubbish + 1 . " elements\n";

Your string does not use the list separator because you are not interpolating the array in the string. For example:

print "\@rubbish now have @rubbish\n";

However, because @rubbish only has one element there is nothing to put the list separator between. The list separator only appears if you have two or more elements.

$ perl -le'
my @rubbish = "anything in here";
local $" = "**";
print "@rubbish";
push @rubbish, "next", "last";
print "@rubbish";
'
anything in here
anything in here**next**last




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
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