how to redefing the default list seperator

--0-970978617-1304604654=:35549
Content-Type: text/plain; charset=us-ascii

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

$testing = "anything in here";
[at] rubbish = $testing;
$" = "in";
print "\ [at] rubbish now have " . $#rubbish + 1 . " elements\n";

--0-970978617-1304604654=:35549--
eventual [ Do, 05 Mai 2011 16:10 ] [ ID #2059156 ]

Re: how to redefing the default list seperator

On 11-05-05 10:10 AM, eventual wrote:
> Hi, How do I change the default list seperator.
> I tried the following but it wont work. Thanks
>
> $testing = "anything in here";
> [at] rubbish = $testing;
> $" = "in";
> print "\ [at] rubbish now have " . $#rubbish + 1 . " elements\n";
>

Try:

[at] rubbish = qw( anything in here );
$" = "in";
print " [at] rubbish now have " . $#rubbish + 1 . " elements\n";

Also:

print " [at] rubbish now have " . scalar( [at] rubbish ) . " elements\n";


--
Just my 0.00000002 million dollars worth,
Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software: Fail early & often.

Eliminate software piracy: use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Shawn H Corey [ Do, 05 Mai 2011 16:13 ] [ ID #2059157 ]

Re: how to redefing the default list seperator

eventual wrote:
> Hi, How do I change the default list seperator.
> I tried the following but it wont work. Thanks
>
> $testing = "anything in here";
> [at] 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 "\ [at] 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 "\ [at] rubbish now have [at] rubbish\n";

However, because [at] 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 [at] rubbish = "anything in here";
local $" = "**";
print " [at] rubbish";
push [at] rubbish, "next", "last";
print " [at] 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-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
jwkrahn [ Do, 05 Mai 2011 20:55 ] [ ID #2059165 ]
Perl » gmane.comp.lang.perl.beginners » how to redefing the default list seperator

Vorheriges Thema: [OFF] OSS Perl Shopping Carts
Nächstes Thema: combinations & permutation : how to generate a list of numbers