Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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


Comment on Re: Converting an index record array into a comma-separated array.
Select or Download Code
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 musing on the Monastery: (5)
As of 2014-12-27 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls