Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 monks are mute...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2016-12-03 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (52 votes). Check out past polls.