Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Converting an index record array into a comma-separated array.

by krujos (Curate)
on Jul 15, 2002 at 15:21 UTC ( #181812=note: print w/ replies, xml ) Need Help??


in reply to Converting an index record array into a comma-separated array.

you could do something like
foreach $element (@array) { $var = $var . $element . ","; }
The dot operator appends, just like the + in java on strings. My example would give you an extra comma, but you could remove it with
$array[@array -1]="";

update added the part about the extra comma

Replies are listed 'Best First'.
Re: Re: Converting an index record array into a comma-separated array.
by Abigail-II (Bishop) on Jul 15, 2002 at 15:49 UTC
    $array[@array -1]="";
    doesn't remove a trailing comma. What it does is replacing the last element of the array with an empty string.

    It's much better to not use an explicite loop, but to use join. Then you don't have to remove any trailing commas either.

    Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://181812]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2016-06-27 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (340 votes). Check out past polls.